Browse Source

temp disable sidemenu and bottom tabs

Daniel Zlotin 7 years ago
parent
commit
67a71860ce

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

@@ -4,9 +4,7 @@ import android.app.Activity;
4 4
 
5 5
 import com.facebook.react.ReactInstanceManager;
6 6
 import com.reactnativenavigation.controllers.Store;
7
-import com.reactnativenavigation.layout.impl.BottomTabsLayout;
8 7
 import com.reactnativenavigation.layout.impl.RootLayout;
9
-import com.reactnativenavigation.layout.impl.SideMenuLayout;
10 8
 import com.reactnativenavigation.layout.impl.StackLayout;
11 9
 
12 10
 public class LayoutFactory {
@@ -32,54 +30,55 @@ public class LayoutFactory {
32 30
 			case Container:
33 31
 				return createContainer(node);
34 32
 			case ContainerStack:
35
-				return createContainerStack(node);
36
-			case BottomTabs:
37
-				return createBottomTabs(node);
38
-			case SideMenuRoot:
39
-				return createSideMenuRoot(node);
40
-			case SideMenuCenter:
41
-				return createSideMenuContent(node);
42
-			case SideMenuLeft:
43
-				return createSideMenuLeft(node);
44
-			case SideMenuRight:
45
-				return createSideMenuRight(node);
46 33
 			default:
47
-				throw new IllegalArgumentException("Invalid node type: " + node.type);
48
-		}
49
-	}
50
-
51
-	private Layout createSideMenuRoot(LayoutNode node) {
52
-		SideMenuLayout sideMenuLayout = new SideMenuLayout(activity);
53
-		for (LayoutNode child : node.children) {
54
-			Layout childLayout = createAndSaveToStore(child);
55
-			switch (child.type) {
56
-				case SideMenuCenter:
57
-					sideMenuLayout.addCenterLayout(childLayout);
58
-					break;
59
-				case SideMenuLeft:
60
-					sideMenuLayout.addLeftLayout(childLayout);
61
-					break;
62
-				case SideMenuRight:
63
-					sideMenuLayout.addRightLayout(childLayout);
64
-					break;
65
-				default:
66
-					throw new IllegalArgumentException("Invalid node type in sideMenu: " + node.type);
67
-			}
34
+				return createContainerStack(node);
35
+//			case BottomTabs:
36
+//				return createBottomTabs(node);
37
+//			case SideMenuRoot:
38
+//				return createSideMenuRoot(node);
39
+//			case SideMenuCenter:
40
+//				return createSideMenuContent(node);
41
+//			case SideMenuLeft:
42
+//				return createSideMenuLeft(node);
43
+//			case SideMenuRight:
44
+//				return createSideMenuRight(node);
45
+//			default:
46
+//				throw new IllegalArgumentException("Invalid node type: " + node.type);
68 47
 		}
69
-		return sideMenuLayout;
70
-	}
71
-
72
-	private Layout createSideMenuContent(LayoutNode node) {
73
-		return createAndSaveToStore(node.children.get(0));
74
-	}
75
-
76
-	private Layout createSideMenuLeft(LayoutNode node) {
77
-		return createAndSaveToStore(node.children.get(0));
78 48
 	}
79 49
 
80
-	private Layout createSideMenuRight(LayoutNode node) {
81
-		return createAndSaveToStore(node.children.get(0));
82
-	}
50
+//	private Layout createSideMenuRoot(LayoutNode node) {
51
+//		SideMenuLayout sideMenuLayout = new SideMenuLayout(activity);
52
+//		for (LayoutNode child : node.children) {
53
+//			Layout childLayout = createAndSaveToStore(child);
54
+//			switch (child.type) {
55
+//				case SideMenuCenter:
56
+//					sideMenuLayout.addCenterLayout(childLayout);
57
+//					break;
58
+//				case SideMenuLeft:
59
+//					sideMenuLayout.addLeftLayout(childLayout);
60
+//					break;
61
+//				case SideMenuRight:
62
+//					sideMenuLayout.addRightLayout(childLayout);
63
+//					break;
64
+//				default:
65
+//					throw new IllegalArgumentException("Invalid node type in sideMenu: " + node.type);
66
+//			}
67
+//		}
68
+//		return sideMenuLayout;
69
+//	}
70
+//
71
+//	private Layout createSideMenuContent(LayoutNode node) {
72
+//		return createAndSaveToStore(node.children.get(0));
73
+//	}
74
+//
75
+//	private Layout createSideMenuLeft(LayoutNode node) {
76
+//		return createAndSaveToStore(node.children.get(0));
77
+//	}
78
+//
79
+//	private Layout createSideMenuRight(LayoutNode node) {
80
+//		return createAndSaveToStore(node.children.get(0));
81
+//	}
83 82
 
84 83
 	private Layout createContainer(LayoutNode node) {
85 84
 		return new RootLayout(activity, node.id, node.data.optString("name"), reactInstanceManager);
@@ -93,13 +92,12 @@ public class LayoutFactory {
93 92
 		return layoutStack;
94 93
 	}
95 94
 
96
-	private Layout createBottomTabs(LayoutNode node) {
97
-		final BottomTabsLayout tabsContainer = new BottomTabsLayout(activity);
98
-		for (int i = 0; i < node.children.size(); i++) {
99
-			final Layout tabLayout = createAndSaveToStore(node.children.get(i));
100
-			tabsContainer.addTab("#" + i, tabLayout);
101
-		}
102
-		return tabsContainer;
103
-	}
104
-
95
+//	private Layout createBottomTabs(LayoutNode node) {
96
+//		final BottomTabsLayout tabsContainer = new BottomTabsLayout(activity);
97
+//		for (int i = 0; i < node.children.size(); i++) {
98
+//			final Layout tabLayout = createAndSaveToStore(node.children.get(i));
99
+//			tabsContainer.addTab("#" + i, tabLayout);
100
+//		}
101
+//		return tabsContainer;
102
+//	}
105 103
 }

+ 80
- 99
lib/android/app/src/main/java/com/reactnativenavigation/layout/impl/BottomTabsLayout.java View File

@@ -1,102 +1,83 @@
1 1
 package com.reactnativenavigation.layout.impl;
2 2
 
3
-import android.app.Activity;
4
-import android.graphics.Color;
5
-import android.support.annotation.NonNull;
6
-import android.support.design.widget.BottomNavigationView;
7
-import android.view.Menu;
8
-import android.view.MenuItem;
9
-import android.view.View;
10
-import android.widget.RelativeLayout;
11
-import android.widget.RelativeLayout.LayoutParams;
12
-
13
-import com.reactnativenavigation.layout.Layout;
14
-import com.reactnativenavigation.utils.CompatUtils;
15
-
16
-import java.util.ArrayList;
17
-import java.util.List;
18
-
19
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
20
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
21
-import static android.widget.RelativeLayout.ABOVE;
22
-import static android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM;
23
-
24
-public class BottomTabsLayout implements Layout, BottomNavigationView.OnNavigationItemSelectedListener {
25
-
26
-	private StackLayout stackLayout;
27
-
28
-	public static class TooManyTabs extends RuntimeException {
29
-		//
30
-	}
31
-
32
-	private final RelativeLayout view;
33
-	private final BottomNavigationView bottomNavigationView;
34
-	private final List<Layout> tabs = new ArrayList<>();
35
-	private int currentTab;
36
-
37
-	public BottomTabsLayout(Activity activity) {
38
-		view = new RelativeLayout(activity);
39
-		view.setId(CompatUtils.generateViewId());
40
-
41
-		bottomNavigationView = new BottomNavigationView(view.getContext());
42
-		bottomNavigationView.setId(CompatUtils.generateViewId());
43
-		bottomNavigationView.setBackgroundColor(Color.DKGRAY);
44
-		bottomNavigationView.setOnNavigationItemSelectedListener(this);
45
-		LayoutParams lp = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
46
-		lp.addRule(ALIGN_PARENT_BOTTOM);
47
-		bottomNavigationView.setLayoutParams(lp);
48
-		view.addView(bottomNavigationView, lp);
49
-	}
50
-
51
-	@Override
52
-	public View getView() {
53
-		return view;
54
-	}
55
-
56
-	@Override
57
-	public void destroy() {
58
-		//
59
-	}
60
-
61
-	@Override
62
-	public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
63
-		hideTab(currentTab);
64
-		currentTab = item.getItemId();
65
-		showTab(currentTab);
66
-		return true;
67
-	}
68
-
69
-	public void addTab(String label, Layout tabLayout) {
70
-		if (tabs.size() >= 5) {
71
-			throw new TooManyTabs();
72
-		}
73
-		int tabId = bottomNavigationView.getMenu().size();
74
-		bottomNavigationView.getMenu().add(0, tabId, Menu.NONE, label);
75
-		LayoutParams tabParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
76
-		tabParams.addRule(ABOVE, bottomNavigationView.getId());
77
-		view.addView(tabLayout.getView(), tabParams);
78
-		tabs.add(tabLayout);
79
-
80
-		if (tabs.size() > 1) {
81
-			tabLayout.getView().setVisibility(View.GONE);
82
-		}
83
-	}
84
-
85
-	private void showTab(int tabId) {
86
-		tabs.get(tabId).getView().setVisibility(View.VISIBLE);
87
-	}
88
-
89
-	private void hideTab(int tabId) {
90
-		tabs.get(tabId).getView().setVisibility(View.GONE);
91
-	}
92
-
93
-	@Override
94
-	public void setParentStackLayout(final StackLayout stackLayout) {
95
-		this.stackLayout = stackLayout;
96
-	}
97
-
98
-	@Override
99
-	public StackLayout getParentStackLayout() {
100
-		return stackLayout;
101
-	}
3
+public class BottomTabsLayout {
4
+
5
+//public class BottomTabsLayout implements Layout, BottomNavigationView.OnNavigationItemSelectedListener {
6
+
7
+//	private StackLayout stackLayout;
8
+//
9
+//	public static class TooManyTabs extends RuntimeException {
10
+//		//
11
+//	}
12
+//
13
+//	private final RelativeLayout view;
14
+//	private final BottomNavigationView bottomNavigationView;
15
+//	private final List<Layout> tabs = new ArrayList<>();
16
+//	private int currentTab;
17
+//
18
+//	public BottomTabsLayout(Activity activity) {
19
+//		view = new RelativeLayout(activity);
20
+//		view.setId(CompatUtils.generateViewId());
21
+//
22
+//		bottomNavigationView = new BottomNavigationView(view.getContext());
23
+//		bottomNavigationView.setId(CompatUtils.generateViewId());
24
+//		bottomNavigationView.setBackgroundColor(Color.DKGRAY);
25
+//		bottomNavigationView.setOnNavigationItemSelectedListener(this);
26
+//		LayoutParams lp = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
27
+//		lp.addRule(ALIGN_PARENT_BOTTOM);
28
+//		bottomNavigationView.setLayoutParams(lp);
29
+//		view.addView(bottomNavigationView, lp);
30
+//	}
31
+//
32
+//	@Override
33
+//	public View getView() {
34
+//		return view;
35
+//	}
36
+//
37
+//	@Override
38
+//	public void destroy() {
39
+//		//
40
+//	}
41
+//
42
+//	@Override
43
+//	public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
44
+//		hideTab(currentTab);
45
+//		currentTab = item.getItemId();
46
+//		showTab(currentTab);
47
+//		return true;
48
+//	}
49
+//
50
+//	public void addTab(String label, Layout tabLayout) {
51
+//		if (tabs.size() >= 5) {
52
+//			throw new TooManyTabs();
53
+//		}
54
+//		int tabId = bottomNavigationView.getMenu().size();
55
+//		bottomNavigationView.getMenu().add(0, tabId, Menu.NONE, label);
56
+//		LayoutParams tabParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
57
+//		tabParams.addRule(ABOVE, bottomNavigationView.getId());
58
+//		view.addView(tabLayout.getView(), tabParams);
59
+//		tabs.add(tabLayout);
60
+//
61
+//		if (tabs.size() > 1) {
62
+//			tabLayout.getView().setVisibility(View.GONE);
63
+//		}
64
+//	}
65
+//
66
+//	private void showTab(int tabId) {
67
+//		tabs.get(tabId).getView().setVisibility(View.VISIBLE);
68
+//	}
69
+//
70
+//	private void hideTab(int tabId) {
71
+//		tabs.get(tabId).getView().setVisibility(View.GONE);
72
+//	}
73
+//
74
+//	@Override
75
+//	public void setParentStackLayout(final StackLayout stackLayout) {
76
+//		this.stackLayout = stackLayout;
77
+//	}
78
+//
79
+//	@Override
80
+//	public StackLayout getParentStackLayout() {
81
+//		return stackLayout;
82
+//	}
102 83
 }

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

@@ -1,64 +1,53 @@
1 1
 package com.reactnativenavigation.layout.impl;
2 2
 
3
-import android.content.Context;
4
-import android.support.v4.widget.DrawerLayout;
5
-import android.view.Gravity;
6
-import android.view.View;
7
-
8
-import com.reactnativenavigation.layout.Layout;
9
-import com.reactnativenavigation.utils.CompatUtils;
10
-
11
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
12
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
13
-
14
-public class SideMenuLayout implements Layout {
15
-
16
-	private DrawerLayout view;
17
-	private StackLayout stackLayout;
18
-
19
-	public SideMenuLayout(Context context) {
20
-		view = new DrawerLayout(context);
21
-		view.setId(CompatUtils.generateViewId());
22
-	}
23
-
24
-	@Override
25
-	public View getView() {
26
-		return view;
27
-	}
28
-
29
-	@Override
30
-	public void destroy() {
31
-		//
32
-	}
33
-
34
-	public void addLeftLayout(final Layout childLayout) {
35
-		View child = childLayout.getView();
36
-		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
37
-		lp.gravity = Gravity.LEFT;
38
-		child.setLayoutParams(lp);
39
-		view.addView(child);
40
-	}
41
-
42
-	public void addRightLayout(final Layout childLayout) {
43
-		View child = childLayout.getView();
44
-		DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
45
-		lp.gravity = Gravity.RIGHT;
46
-		child.setLayoutParams(lp);
47
-		view.addView(child);
48
-	}
49
-
50
-	public void addCenterLayout(final Layout childLayout) {
51
-		View child = childLayout.getView();
52
-		view.addView(child);
53
-	}
54
-
55
-	@Override
56
-	public void setParentStackLayout(final StackLayout stackLayout) {
57
-		this.stackLayout = stackLayout;
58
-	}
59
-
60
-	@Override
61
-	public StackLayout getParentStackLayout() {
62
-		return stackLayout;
63
-	}
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
+//	}
64 53
 }