Search in sources :

Example 1 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class ParentControllerTest method findControllerById_Recursive.

@Test
public void findControllerById_Recursive() {
    StackController stackController = TestUtils.newStackController(activity).build();
    stackController.ensureViewIsCreated();
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
    stackController.push(child1, new CommandListenerAdapter());
    stackController.push(child2, new CommandListenerAdapter());
    children.add(stackController);
    assertThat(uut.findController("child2")).isEqualTo(child2);
}
Also used : Options(com.reactnativenavigation.options.Options) 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 2 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class TopTabsViewControllerTest method applyOptions_tabsAreRemovedAfterViewDisappears.

@Test
public void applyOptions_tabsAreRemovedAfterViewDisappears() {
    StackController stackController = TestUtils.newStackController(activity).build();
    stackController.ensureViewIsCreated();
    ViewController<?> first = new SimpleViewController(activity, childRegistry, "first", Options.EMPTY);
    disablePushAnimation(first, uut);
    stackController.push(first, new CommandListenerAdapter());
    stackController.push(uut, new CommandListenerAdapter());
    uut.onViewWillAppear();
    assertThat(ViewHelper.isVisible(stackController.getTopBar().getTopTabs())).isTrue();
    disablePopAnimation(uut);
    stackController.pop(Options.EMPTY, new CommandListenerAdapter());
    first.onViewWillAppear();
    assertThat(ViewHelper.isVisible(stackController.getTopBar().getTopTabs())).isFalse();
}
Also used : 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 3 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class BottomTabsController method onTabSelected.

@Override
public boolean onTabSelected(int index, boolean wasSelected) {
    ViewController<?> stack = tabs.get(index);
    BottomTabOptions options = stack.resolveCurrentOptions().bottomTabOptions;
    eventEmitter.emitBottomTabPressed(index);
    if (options.selectTabOnPress.get(true)) {
        eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
        if (!wasSelected) {
            selectTab(index);
        }
    }
    if (options.popToRoot.get(false) && wasSelected && stack instanceof StackController) {
        ((StackController) stack).popToRoot(Options.EMPTY, new CommandListenerAdapter());
    }
    return false;
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) BottomTabOptions(com.reactnativenavigation.options.BottomTabOptions) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter)

Example 4 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method pop_byStackId.

@Test
public void pop_byStackId() {
    disablePushAnimation(child1, child2);
    disablePopAnimation(child2, child1);
    StackController stack = newStack(child1, child2);
    stack.ensureViewIsCreated();
    uut.setRoot(stack, new CommandListenerAdapter(), reactInstanceManager);
    uut.pop(stack.getId(), Options.EMPTY, new CommandListenerAdapter());
    assertThat(stack.getChildControllers()).containsOnly(child1);
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 5 with StackController

use of com.reactnativenavigation.viewcontrollers.stack.StackController in project react-native-navigation by wix.

the class NavigatorTest method destroy_destroyedRoot.

@Test
public void destroy_destroyedRoot() {
    disablePushAnimation(child1);
    StackController spy = spy(parentController);
    spy.options.animations.setRoot.getEnter().enabled = new Bool(false);
    uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
    spy.push(child1, new CommandListenerAdapter());
    activityController.destroy();
    verify(spy, times(1)).destroy();
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)20 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)19 BaseTest (com.reactnativenavigation.BaseTest)18 Test (org.junit.Test)18 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Bool (com.reactnativenavigation.options.params.Bool)3 Options (com.reactnativenavigation.options.Options)2 ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 BottomTabOptions (com.reactnativenavigation.options.BottomTabOptions)1 Text (com.reactnativenavigation.options.params.Text)1