Search in sources :

Example 1 with BottomTabsController

use of com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController in project react-native-navigation by wix.

the class NavigatorTest method pop_FromCorrectStackByFindingChildId_Promise.

@Test
public void pop_FromCorrectStackByFindingChildId_Promise() {
    disablePushAnimation(child4);
    StackController stack1 = newStack(child1);
    final StackController stack2 = newStack(child2, child3);
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    idleMainLooper();
    CommandListenerAdapter listener = spy(new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
        }
    });
    stack2.push(child4, listener);
    verify(listener).onSuccess(child4.getId());
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 2 with BottomTabsController

use of com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController in project react-native-navigation by wix.

the class NavigatorTest method popToRoot.

@Test
public void popToRoot() {
    StackController stack1 = newStack(child1);
    StackController stack2 = newStack(child2, child3, child4);
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    stack2.push(child5, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            uut.popToRoot(child3.getId(), Options.EMPTY, new CommandListenerAdapter());
            assertThat(stack2.getChildControllers()).containsOnly(child2);
        }
    });
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 3 with BottomTabsController

use of com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController in project react-native-navigation by wix.

the class NavigatorTest method pop_FromCorrectStackByFindingChildId.

@Test
public void pop_FromCorrectStackByFindingChildId() {
    StackController stack1 = newStack(child1);
    StackController stack2 = newStack(child2);
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    stack2.push(child3, new CommandListenerAdapter() {

        @Override
        public void onSuccess(String childId) {
            stack2.push(child4, new CommandListenerAdapter() {

                @Override
                public void onSuccess(String childId) {
                    uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
                    assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
                }
            });
        }
    });
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 4 with BottomTabsController

use of com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController in project react-native-navigation by wix.

the class NavigatorTest method push_OnCorrectStackByFindingChildId.

@Test
public void push_OnCorrectStackByFindingChildId() {
    StackController stack1 = newStack();
    stack1.ensureViewIsCreated();
    StackController stack2 = newStack();
    stack2.ensureViewIsCreated();
    stack1.push(child1, new CommandListenerAdapter());
    stack2.push(child2, new CommandListenerAdapter());
    BottomTabsController bottomTabsController = newTabs(Arrays.asList(stack1, stack2));
    uut.setRoot(bottomTabsController, new CommandListenerAdapter(), reactInstanceManager);
    SimpleViewController newChild = new SimpleViewController(activity, childRegistry, "new child", tabOptions);
    uut.push(child2.getId(), newChild, new CommandListenerAdapter());
    assertThat(stack1.getChildControllers()).doesNotContain(newChild);
    assertThat(stack2.getChildControllers()).contains(newChild);
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 5 with BottomTabsController

use of com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController in project react-native-navigation by wix.

the class LayoutFactory method createBottomTabs.

private ViewController<?> createBottomTabs(LayoutNode node) {
    List<ViewController<?>> tabs = map(node.children, this::create);
    BottomTabsPresenter bottomTabsPresenter = new BottomTabsPresenter(tabs, defaultOptions, new BottomTabsAnimator());
    return new BottomTabsController(activity, tabs, childRegistry, eventEmitter, new ImageLoader(), node.id, parseOptions(node.getOptions()), new Presenter(activity, defaultOptions), new BottomTabsAttacher(tabs, bottomTabsPresenter, defaultOptions), bottomTabsPresenter, new BottomTabPresenter(activity, tabs, new ImageLoader(), new TypefaceLoader(activity), defaultOptions));
}
Also used : BottomTabsController(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController) BottomTabPresenter(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) ExternalComponentViewController(com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController) StackPresenter(com.reactnativenavigation.viewcontrollers.stack.StackPresenter) BottomTabPresenter(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter) BottomTabsPresenter(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter) SideMenuPresenter(com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ExternalComponentPresenter(com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TypefaceLoader(com.reactnativenavigation.options.parsers.TypefaceLoader) BottomTabsPresenter(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter) BottomTabsAttacher(com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher) ImageLoader(com.reactnativenavigation.utils.ImageLoader) BottomTabsAnimator(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsAnimator)

Aggregations

BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)6 BaseTest (com.reactnativenavigation.BaseTest)5 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)5 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)5 Test (org.junit.Test)5 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)1 TypefaceLoader (com.reactnativenavigation.options.parsers.TypefaceLoader)1 ImageLoader (com.reactnativenavigation.utils.ImageLoader)1 BottomTabPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter)1 BottomTabsAnimator (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsAnimator)1 BottomTabsPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter)1 BottomTabsAttacher (com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher)1 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)1 ComponentViewController (com.reactnativenavigation.viewcontrollers.component.ComponentViewController)1 ExternalComponentPresenter (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter)1 ExternalComponentViewController (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController)1 SideMenuPresenter (com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter)1 StackPresenter (com.reactnativenavigation.viewcontrollers.stack.StackPresenter)1 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)1 ViewController (com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController)1