Browse Source

Top tabs android2 (#2346)

* Restructure TopTabsLayout

* Refactor Containers

* Consolidate view creators. For some reason we had double abstraction layer and had creators invoking creators
* Rename ContainerView to ContainerLayout

* fix test
Guy Carmeli 7 years ago
parent
commit
c50f7752e8
No account linked to committer's email address
20 changed files with 147 additions and 83 deletions
  1. 9
    13
      lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java
  2. 3
    3
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java
  3. 3
    3
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ContainerViewController.java
  4. 0
    25
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabController.java
  5. 7
    1
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsController.java
  6. 2
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewPager.java
  7. 7
    0
      lib/android/app/src/main/java/com/reactnativenavigation/views/Container.java
  8. 4
    3
      lib/android/app/src/main/java/com/reactnativenavigation/views/ContainerLayout.java
  9. 7
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/ContainerViewCreator.java
  10. 0
    4
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTab.java
  11. 9
    5
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabCreator.java
  12. 30
    0
      lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsLayout.java
  13. 1
    2
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleContainerViewController.java
  14. 9
    4
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestContainerLayout.java
  15. 1
    1
      lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestContainerViewCreator.java
  16. 2
    2
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ContainerViewControllerTest.java
  17. 8
    10
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java
  18. 40
    0
      playground/src/containers/TopTabScreen.js
  19. 3
    3
      playground/src/containers/WelcomeScreen.js
  20. 2
    0
      playground/src/containers/index.js

+ 9
- 13
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java View File

10
 import com.reactnativenavigation.viewcontrollers.StackController;
10
 import com.reactnativenavigation.viewcontrollers.StackController;
11
 import com.reactnativenavigation.viewcontrollers.ViewController;
11
 import com.reactnativenavigation.viewcontrollers.ViewController;
12
 import com.reactnativenavigation.viewcontrollers.overlay.DialogViewController;
12
 import com.reactnativenavigation.viewcontrollers.overlay.DialogViewController;
13
-import com.reactnativenavigation.viewcontrollers.toptabs.TopTabController;
14
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
13
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
15
 import com.reactnativenavigation.views.ContainerViewCreator;
14
 import com.reactnativenavigation.views.ContainerViewCreator;
16
 import com.reactnativenavigation.views.TopTabCreator;
15
 import com.reactnativenavigation.views.TopTabCreator;
33
 	public ViewController create(final LayoutNode node) {
32
 	public ViewController create(final LayoutNode node) {
34
 		switch (node.type) {
33
 		switch (node.type) {
35
 			case Container:
34
 			case Container:
36
-				return createContainer(node);
35
+				return createContainer(node, new ContainerViewCreator(reactInstanceManager));
37
 			case ContainerStack:
36
 			case ContainerStack:
38
 				return createContainerStack(node);
37
 				return createContainerStack(node);
39
 			case BottomTabs:
38
 			case BottomTabs:
51
             case TopTabsContainer:
50
             case TopTabsContainer:
52
                 return createTopTabsContainer(node);
51
                 return createTopTabsContainer(node);
53
             case TopTab:
52
             case TopTab:
54
-                return createTopTabContainer(node);
53
+                return createContainer(node, new TopTabCreator(reactInstanceManager));
55
 			default:
54
 			default:
56
 				throw new IllegalArgumentException("Invalid node type: " + node.type);
55
 				throw new IllegalArgumentException("Invalid node type: " + node.type);
57
 		}
56
 		}
90
 		return create(node.children.get(0));
89
 		return create(node.children.get(0));
91
 	}
90
 	}
92
 
91
 
93
-	private ViewController createContainer(LayoutNode node) {
92
+	private ViewController createContainer(LayoutNode node, ContainerViewController.ReactViewCreator reactViewCreator) {
94
 		String id = node.id;
93
 		String id = node.id;
95
 		String name = node.data.optString("name");
94
 		String name = node.data.optString("name");
96
 		NavigationOptions navigationOptions = NavigationOptions.parse(node.data.optJSONObject("navigationOptions"), defaultOptions);
95
 		NavigationOptions navigationOptions = NavigationOptions.parse(node.data.optJSONObject("navigationOptions"), defaultOptions);
97
-		return new ContainerViewController(activity, id, name, new ContainerViewCreator(new ReactContainerViewCreator(reactInstanceManager)), navigationOptions);
96
+		return new ContainerViewController(activity,
97
+                id,
98
+                name,
99
+                reactViewCreator,
100
+                navigationOptions
101
+        );
98
 	}
102
 	}
99
 
103
 
100
 	private ViewController createContainerStack(LayoutNode node) {
104
 	private ViewController createContainerStack(LayoutNode node) {
129
         }
133
         }
130
         return new TopTabsController(activity, node.id, tabs);
134
         return new TopTabsController(activity, node.id, tabs);
131
     }
135
     }
132
-
133
-    private TopTabController createTopTabContainer(LayoutNode node) {
134
-        String name = node.data.optString("name");
135
-        return new TopTabController(activity,
136
-                node.id,
137
-                name,
138
-                new TopTabCreator(new ReactContainerViewCreator(reactInstanceManager)));
139
-    }
140
 }
136
 }

+ 3
- 3
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java View File

8
 import com.reactnativenavigation.parse.TopTabsOptions;
8
 import com.reactnativenavigation.parse.TopTabsOptions;
9
 import com.reactnativenavigation.utils.TypefaceLoader;
9
 import com.reactnativenavigation.utils.TypefaceLoader;
10
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
10
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
11
-import com.reactnativenavigation.views.ContainerView;
11
+import com.reactnativenavigation.views.ContainerLayout;
12
 
12
 
13
 public class OptionsPresenter {
13
 public class OptionsPresenter {
14
 
14
 
47
 			return;
47
 			return;
48
 		}
48
 		}
49
 		if (animated == NavigationOptions.BooleanOptions.True) {
49
 		if (animated == NavigationOptions.BooleanOptions.True) {
50
-			ContainerView topBarContainerView = (ContainerView) controller.getContainerView();
50
+			ContainerLayout topBarContainerView = (ContainerLayout) controller.getContainerView();
51
 			animator.animateShowTopBar(controller.getTopBar(), topBarContainerView.getReactView().asView());
51
 			animator.animateShowTopBar(controller.getTopBar(), topBarContainerView.getReactView().asView());
52
 		} else {
52
 		} else {
53
 			controller.getTopBar().setVisibility(View.VISIBLE);
53
 			controller.getTopBar().setVisibility(View.VISIBLE);
59
 			return;
59
 			return;
60
 		}
60
 		}
61
 		if (animated == NavigationOptions.BooleanOptions.True) {
61
 		if (animated == NavigationOptions.BooleanOptions.True) {
62
-			ContainerView topBarContainerView = (ContainerView) controller.getContainerView();
62
+			ContainerLayout topBarContainerView = (ContainerLayout) controller.getContainerView();
63
 			animator.animateHideTopBar(controller.getTopBar(), topBarContainerView.getReactView().asView());
63
 			animator.animateHideTopBar(controller.getTopBar(), topBarContainerView.getReactView().asView());
64
 		} else {
64
 		} else {
65
 			controller.getTopBar().setVisibility(View.GONE);
65
 			controller.getTopBar().setVisibility(View.GONE);

+ 3
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ContainerViewController.java View File

7
 import com.reactnativenavigation.parse.NavigationOptions;
7
 import com.reactnativenavigation.parse.NavigationOptions;
8
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
8
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
9
 import com.reactnativenavigation.presentation.OptionsPresenter;
9
 import com.reactnativenavigation.presentation.OptionsPresenter;
10
+import com.reactnativenavigation.views.Container;
10
 import com.reactnativenavigation.views.TopBar;
11
 import com.reactnativenavigation.views.TopBar;
11
-import com.reactnativenavigation.views.ContainerView;
12
 
12
 
13
 public class ContainerViewController extends ViewController implements NavigationOptionsListener {
13
 public class ContainerViewController extends ViewController implements NavigationOptionsListener {
14
 
14
 
96
 	@Override
96
 	@Override
97
 	protected View createView() {
97
 	protected View createView() {
98
 		containerView = viewCreator.create(getActivity(), getId(), containerName);
98
 		containerView = viewCreator.create(getActivity(), getId(), containerName);
99
-		if (containerView instanceof ContainerView) {
100
-			topBar = ((ContainerView) containerView).getTopBar();
99
+		if (containerView instanceof Container) {
100
+			topBar = ((Container) containerView).getTopBar();
101
 		}
101
 		}
102
 		return containerView.asView();
102
 		return containerView.asView();
103
 	}
103
 	}

+ 0
- 25
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabController.java View File

1
-package com.reactnativenavigation.viewcontrollers.toptabs;
2
-
3
-import android.app.Activity;
4
-import android.support.annotation.NonNull;
5
-import android.view.ViewGroup;
6
-
7
-import com.reactnativenavigation.viewcontrollers.ViewController;
8
-import com.reactnativenavigation.views.TopTabCreator;
9
-
10
-public class TopTabController extends ViewController {
11
-    private String name;
12
-    private TopTabCreator topTabCreator;
13
-
14
-    public TopTabController(Activity activity, String id, String name, TopTabCreator topTabCreator) {
15
-        super(activity, id);
16
-        this.name = name;
17
-        this.topTabCreator = topTabCreator;
18
-    }
19
-
20
-    @NonNull
21
-    @Override
22
-    protected ViewGroup createView() {
23
-        return (ViewGroup) topTabCreator.create(getActivity(), getId(), name);
24
-    }
25
-}

+ 7
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsController.java View File

6
 
6
 
7
 import com.reactnativenavigation.viewcontrollers.ParentController;
7
 import com.reactnativenavigation.viewcontrollers.ParentController;
8
 import com.reactnativenavigation.viewcontrollers.ViewController;
8
 import com.reactnativenavigation.viewcontrollers.ViewController;
9
+import com.reactnativenavigation.views.TopTabsLayout;
9
 
10
 
10
 import java.util.Collection;
11
 import java.util.Collection;
11
 import java.util.List;
12
 import java.util.List;
22
     @NonNull
23
     @NonNull
23
     @Override
24
     @Override
24
     protected ViewGroup createView() {
25
     protected ViewGroup createView() {
25
-        return new TopTabsViewPager(getActivity(), tabs);
26
+        return new TopTabsLayout(getActivity(), tabs);
26
     }
27
     }
27
 
28
 
28
     @NonNull
29
     @NonNull
30
     public Collection<ViewController> getChildControllers() {
31
     public Collection<ViewController> getChildControllers() {
31
         return tabs;
32
         return tabs;
32
     }
33
     }
34
+
35
+    @Override
36
+    protected boolean isViewShown() {
37
+        return super.isViewShown();
38
+    }
33
 }
39
 }

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewPager.java View File

1
 package com.reactnativenavigation.viewcontrollers.toptabs;
1
 package com.reactnativenavigation.viewcontrollers.toptabs;
2
 
2
 
3
+import android.annotation.SuppressLint;
3
 import android.content.Context;
4
 import android.content.Context;
4
 import android.support.v4.view.ViewPager;
5
 import android.support.v4.view.ViewPager;
5
 import android.view.View;
6
 import android.view.View;
12
 
13
 
13
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
14
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
14
 
15
 
16
+@SuppressLint("ViewConstructor")
15
 public class TopTabsViewPager extends ViewPager implements ContainerViewController.IReactView {
17
 public class TopTabsViewPager extends ViewPager implements ContainerViewController.IReactView {
16
     private static final int OFFSCREEN_PAGE_LIMIT = 99;
18
     private static final int OFFSCREEN_PAGE_LIMIT = 99;
17
     private final List<ViewController> tabs;
19
     private final List<ViewController> tabs;

+ 7
- 0
lib/android/app/src/main/java/com/reactnativenavigation/views/Container.java View File

1
+package com.reactnativenavigation.views;
2
+
3
+import com.reactnativenavigation.viewcontrollers.ContainerViewController;
4
+
5
+public interface Container extends ContainerViewController.IReactView {
6
+    TopBar getTopBar();
7
+}

lib/android/app/src/main/java/com/reactnativenavigation/views/ContainerView.java → lib/android/app/src/main/java/com/reactnativenavigation/views/ContainerLayout.java View File

6
 
6
 
7
 import com.reactnativenavigation.viewcontrollers.ContainerViewController.IReactView;
7
 import com.reactnativenavigation.viewcontrollers.ContainerViewController.IReactView;
8
 
8
 
9
-public class ContainerView extends LinearLayout implements IReactView {
9
+public class ContainerLayout extends LinearLayout implements Container {
10
 
10
 
11
 	private TopBar topBar;
11
 	private TopBar topBar;
12
 	private IReactView reactView;
12
 	private IReactView reactView;
13
 
13
 
14
-	public ContainerView(Context context, IReactView reactView) {
14
+	public ContainerLayout(Context context, IReactView reactView) {
15
 		super(context);
15
 		super(context);
16
 		this.topBar = new TopBar(context);
16
 		this.topBar = new TopBar(context);
17
 		this.reactView = reactView;
17
 		this.reactView = reactView;
24
 		addView(reactView.asView());
24
 		addView(reactView.asView());
25
 	}
25
 	}
26
 
26
 
27
-	public ContainerView(Context context) {
27
+	public ContainerLayout(Context context) {
28
 		super(context);
28
 		super(context);
29
 	}
29
 	}
30
 
30
 
53
 		reactView.sendContainerStop();
53
 		reactView.sendContainerStop();
54
 	}
54
 	}
55
 
55
 
56
+    @Override
56
 	public TopBar getTopBar() {
57
 	public TopBar getTopBar() {
57
 		return topBar;
58
 		return topBar;
58
 	}
59
 	}

+ 7
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/ContainerViewCreator.java View File

2
 
2
 
3
 import android.app.Activity;
3
 import android.app.Activity;
4
 
4
 
5
+import com.facebook.react.ReactInstanceManager;
6
+import com.reactnativenavigation.react.ReactContainerViewCreator;
5
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
7
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
6
 
8
 
7
 public class ContainerViewCreator implements ContainerViewController.ReactViewCreator {
9
 public class ContainerViewCreator implements ContainerViewController.ReactViewCreator {
8
 
10
 
9
-	private ContainerViewController.ReactViewCreator creator;
11
+    private ReactInstanceManager instanceManager;
10
 
12
 
11
-	public ContainerViewCreator(ContainerViewController.ReactViewCreator creator) {
12
-		this.creator = creator;
13
+    public ContainerViewCreator(ReactInstanceManager instanceManager) {
14
+        this.instanceManager = instanceManager;
13
 	}
15
 	}
14
 
16
 
15
 	@Override
17
 	@Override
16
 	public ContainerViewController.IReactView create(Activity activity, String containerId, String containerName) {
18
 	public ContainerViewController.IReactView create(Activity activity, String containerId, String containerName) {
17
-        return new ContainerView(activity, creator.create(activity, containerId, containerName));
19
+        ContainerViewController.IReactView reactView = new ReactContainerViewCreator(instanceManager).create(activity, containerId, containerName);
20
+        return new ContainerLayout(activity, reactView);
18
 	}
21
 	}
19
 }
22
 }

+ 0
- 4
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTab.java View File

48
 	public void sendContainerStop() {
48
 	public void sendContainerStop() {
49
 		reactView.sendContainerStop();
49
 		reactView.sendContainerStop();
50
 	}
50
 	}
51
-
52
-	public IReactView getReactView() {
53
-		return reactView;
54
-	}
55
 }
51
 }

+ 9
- 5
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabCreator.java View File

2
 
2
 
3
 import android.app.Activity;
3
 import android.app.Activity;
4
 
4
 
5
+import com.facebook.react.ReactInstanceManager;
6
+import com.reactnativenavigation.react.ReactContainerViewCreator;
5
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
7
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
6
 
8
 
7
 public class TopTabCreator implements ContainerViewController.ReactViewCreator {
9
 public class TopTabCreator implements ContainerViewController.ReactViewCreator {
8
 
10
 
9
-	private ContainerViewController.ReactViewCreator creator;
10
 
11
 
11
-	public TopTabCreator(ContainerViewController.ReactViewCreator creator) {
12
-		this.creator = creator;
13
-	}
12
+    private ReactInstanceManager instanceManager;
13
+
14
+    public TopTabCreator(ReactInstanceManager instanceManager) {
15
+        this.instanceManager = instanceManager;
16
+    }
14
 
17
 
15
 	@Override
18
 	@Override
16
 	public ContainerViewController.IReactView create(Activity activity, String containerId, String containerName) {
19
 	public ContainerViewController.IReactView create(Activity activity, String containerId, String containerName) {
17
-        return new TopTab(activity, creator.create(activity, containerId, containerName));
20
+        ContainerViewController.IReactView reactView = new ReactContainerViewCreator(instanceManager).create(activity, containerId, containerName);
21
+        return new TopTab(activity, reactView);
18
 	}
22
 	}
19
 }
23
 }

+ 30
- 0
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsLayout.java View File

1
+package com.reactnativenavigation.views;
2
+
3
+import android.annotation.SuppressLint;
4
+import android.content.Context;
5
+import android.widget.LinearLayout;
6
+
7
+import com.reactnativenavigation.viewcontrollers.ViewController;
8
+import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsViewPager;
9
+
10
+import java.util.List;
11
+
12
+@SuppressLint("ViewConstructor")
13
+public class TopTabsLayout extends LinearLayout {
14
+
15
+    private TopBar topBar;
16
+    private TopTabsViewPager viewPager;
17
+
18
+    public TopTabsLayout(Context context, List<ViewController> tabs) {
19
+        super(context);
20
+        topBar = new TopBar(context);
21
+        viewPager = new TopTabsViewPager(context, tabs);
22
+        initViews();
23
+    }
24
+
25
+    private void initViews() {
26
+        setOrientation(VERTICAL);
27
+        addView(topBar);
28
+        addView(viewPager);
29
+    }
30
+}

+ 1
- 2
lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleContainerViewController.java View File

4
 
4
 
5
 import com.reactnativenavigation.parse.NavigationOptions;
5
 import com.reactnativenavigation.parse.NavigationOptions;
6
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
6
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
7
-import com.reactnativenavigation.views.ContainerViewCreator;
8
 
7
 
9
 public class SimpleContainerViewController extends ContainerViewController {
8
 public class SimpleContainerViewController extends ContainerViewController {
10
 	public SimpleContainerViewController(final Activity activity, final String id) {
9
 	public SimpleContainerViewController(final Activity activity, final String id) {
11
-		super(activity, id, "theContainerName", new ContainerViewCreator(new TestContainerViewCreator()), new NavigationOptions());
10
+		super(activity, id, "theContainerName", new TestContainerViewCreator(), new NavigationOptions());
12
 	}
11
 	}
13
 }
12
 }

lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestContainerView.java → lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestContainerLayout.java View File

4
 import android.view.View;
4
 import android.view.View;
5
 
5
 
6
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
6
 import com.reactnativenavigation.viewcontrollers.ContainerViewController;
7
+import com.reactnativenavigation.views.Container;
7
 import com.reactnativenavigation.views.TopBar;
8
 import com.reactnativenavigation.views.TopBar;
8
 
9
 
9
-public class TestContainerView extends View implements ContainerViewController.IReactView {
10
+public class TestContainerLayout extends View implements ContainerViewController.IReactView, Container {
10
 
11
 
11
 	private TopBar topBar;
12
 	private TopBar topBar;
12
 
13
 
13
-	public TestContainerView(final Context context) {
14
+	public TestContainerLayout(final Context context) {
14
 		super(context);
15
 		super(context);
15
 		topBar = new TopBar(context);
16
 		topBar = new TopBar(context);
16
-
17
 	}
17
 	}
18
 
18
 
19
-	@Override
19
+    @Override
20
 	public boolean isReady() {
20
 	public boolean isReady() {
21
 		return false;
21
 		return false;
22
 	}
22
 	}
37
 	@Override
37
 	@Override
38
 	public void sendContainerStop() {
38
 	public void sendContainerStop() {
39
 	}
39
 	}
40
+
41
+    @Override
42
+    public TopBar getTopBar() {
43
+        return topBar;
44
+    }
40
 }
45
 }

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestContainerViewCreator.java View File

8
 public class TestContainerViewCreator implements ReactViewCreator {
8
 public class TestContainerViewCreator implements ReactViewCreator {
9
 	@Override
9
 	@Override
10
 	public ContainerViewController.IReactView create(final Activity activity, final String containerId, final String containerName) {
10
 	public ContainerViewController.IReactView create(final Activity activity, final String containerId, final String containerName) {
11
-		return new TestContainerView(activity);
11
+		return new TestContainerLayout(activity);
12
 	}
12
 	}
13
 }
13
 }

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ContainerViewControllerTest.java View File

3
 import android.app.Activity;
3
 import android.app.Activity;
4
 
4
 
5
 import com.reactnativenavigation.BaseTest;
5
 import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.mocks.TestContainerView;
6
+import com.reactnativenavigation.mocks.TestContainerLayout;
7
 import com.reactnativenavigation.parse.NavigationOptions;
7
 import com.reactnativenavigation.parse.NavigationOptions;
8
 
8
 
9
 import org.junit.Test;
9
 import org.junit.Test;
22
 	public void beforeEach() {
22
 	public void beforeEach() {
23
 		super.beforeEach();
23
 		super.beforeEach();
24
 		Activity activity = newActivity();
24
 		Activity activity = newActivity();
25
-		view = spy(new TestContainerView(activity));
25
+		view = spy(new TestContainerLayout(activity));
26
 		uut = new ContainerViewController(activity, "containerId1", "containerName", new ContainerViewController.ReactViewCreator() {
26
 		uut = new ContainerViewController(activity, "containerId1", "containerName", new ContainerViewController.ReactViewCreator() {
27
 			@Override
27
 			@Override
28
 			public ContainerViewController.IReactView create(final Activity activity1, final String containerId, final String containerName) {
28
 			public ContainerViewController.IReactView create(final Activity activity1, final String containerId, final String containerName) {

+ 8
- 10
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java View File

6
 import android.view.View;
6
 import android.view.View;
7
 
7
 
8
 import com.reactnativenavigation.BaseTest;
8
 import com.reactnativenavigation.BaseTest;
9
-import com.reactnativenavigation.mocks.TestContainerView;
9
+import com.reactnativenavigation.mocks.TestContainerLayout;
10
 import com.reactnativenavigation.parse.NavigationOptions;
10
 import com.reactnativenavigation.parse.NavigationOptions;
11
-import com.reactnativenavigation.views.ContainerViewCreator;
12
 
11
 
13
 import org.junit.Test;
12
 import org.junit.Test;
14
 
13
 
15
 import static org.assertj.core.api.Java6Assertions.assertThat;
14
 import static org.assertj.core.api.Java6Assertions.assertThat;
16
 import static org.mockito.Mockito.spy;
15
 import static org.mockito.Mockito.spy;
17
-import static org.mockito.Mockito.verify;
18
 
16
 
19
 public class OptionsApplyingTest extends BaseTest {
17
 public class OptionsApplyingTest extends BaseTest {
20
 	private Activity activity;
18
 	private Activity activity;
27
 		super.beforeEach();
25
 		super.beforeEach();
28
 		activity = newActivity();
26
 		activity = newActivity();
29
 		initialNavigationOptions = new NavigationOptions();
27
 		initialNavigationOptions = new NavigationOptions();
30
-		view = spy(new TestContainerView(activity));
28
+		view = spy(new TestContainerLayout(activity));
31
 		uut = new ContainerViewController(activity, "containerId1", "containerName",
29
 		uut = new ContainerViewController(activity, "containerId1", "containerName",
32
-				new ContainerViewCreator(new ContainerViewController.ReactViewCreator() {
33
-					@Override
34
-					public ContainerViewController.IReactView create(final Activity activity1, final String containerId, final String containerName) {
35
-						return view;
36
-					}
37
-				}), initialNavigationOptions);
30
+                new ContainerViewController.ReactViewCreator() {
31
+                    @Override
32
+                    public ContainerViewController.IReactView create(final Activity activity1, final String containerId, final String containerName) {
33
+                        return view;
34
+                    }
35
+                }, initialNavigationOptions);
38
 	}
36
 	}
39
 
37
 
40
 	@Test
38
 	@Test

+ 40
- 0
playground/src/containers/TopTabScreen.js View File

1
+const React = require('react');
2
+const { PureComponent } = require('react');
3
+const { View, Text } = require('react-native');
4
+
5
+class TopTabScreen extends PureComponent {
6
+  render() {
7
+    return (
8
+      <View style={styles.root}>
9
+        <Text style={styles.h1}>{this.props.text || 'Top Tab Screen'}</Text>
10
+        <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
11
+      </View>
12
+    );
13
+  }
14
+}
15
+
16
+module.exports = TopTabScreen;
17
+
18
+const styles = {
19
+  root: {
20
+    flexGrow: 1,
21
+    justifyContent: 'center',
22
+    alignItems: 'center',
23
+    backgroundColor: '#f5fcff'
24
+  },
25
+  h1: {
26
+    fontSize: 24,
27
+    textAlign: 'center',
28
+    margin: 10
29
+  },
30
+  h2: {
31
+    fontSize: 12,
32
+    textAlign: 'center',
33
+    margin: 10
34
+  },
35
+  footer: {
36
+    fontSize: 10,
37
+    color: '#888',
38
+    marginTop: 10
39
+  }
40
+};

+ 3
- 3
playground/src/containers/WelcomeScreen.js View File

152
       topTabs: [
152
       topTabs: [
153
         {
153
         {
154
           container: {
154
           container: {
155
-            name: 'navigation.playground.TextScreen',
155
+            name: 'navigation.playground.TopTabScreen',
156
             passProps: {
156
             passProps: {
157
               text: 'This is top tab 1'
157
               text: 'This is top tab 1'
158
             }
158
             }
160
         },
160
         },
161
         {
161
         {
162
           container: {
162
           container: {
163
-            name: 'navigation.playground.TextScreen',
163
+            name: 'navigation.playground.TopTabScreen',
164
             passProps: {
164
             passProps: {
165
               text: 'This is top tab 2'
165
               text: 'This is top tab 2'
166
             }
166
             }
168
         },
168
         },
169
         {
169
         {
170
           container: {
170
           container: {
171
-            name: 'navigation.playground.TextScreen',
171
+            name: 'navigation.playground.TopTabScreen',
172
             passProps: {
172
             passProps: {
173
               text: 'This is top tab 3'
173
               text: 'This is top tab 3'
174
             }
174
             }

+ 2
- 0
playground/src/containers/index.js View File

13
 const CustomDialog = require('./CustomDialog');
13
 const CustomDialog = require('./CustomDialog');
14
 const BandHandlerScreen = require('./BackHandlerScreen');
14
 const BandHandlerScreen = require('./BackHandlerScreen');
15
 const SideMenuScreen = require('./SideMenuScreen');
15
 const SideMenuScreen = require('./SideMenuScreen');
16
+const TopTabScreen = require('./TopTabScreen');
16
 
17
 
17
 function registerContainers() {
18
 function registerContainers() {
18
   Navigation.registerContainer(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
19
   Navigation.registerContainer(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
29
   Navigation.registerContainer('navigation.playground.CustomDialog', () => CustomDialog);
30
   Navigation.registerContainer('navigation.playground.CustomDialog', () => CustomDialog);
30
   Navigation.registerContainer('navigation.playground.BackHandlerScreen', () => BandHandlerScreen);
31
   Navigation.registerContainer('navigation.playground.BackHandlerScreen', () => BandHandlerScreen);
31
   Navigation.registerContainer('navigation.playground.SideMenuScreen', () => SideMenuScreen);
32
   Navigation.registerContainer('navigation.playground.SideMenuScreen', () => SideMenuScreen);
33
+  Navigation.registerContainer('navigation.playground.TopTabScreen', () => TopTabScreen);
32
 }
34
 }
33
 
35
 
34
 module.exports = {
36
 module.exports = {