Search in sources :

Example 6 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter 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 7 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method setRoot_delegatesToRootPresenter.

@Test
public void setRoot_delegatesToRootPresenter() {
    CommandListenerAdapter listener = new CommandListenerAdapter();
    uut.setRoot(child1, listener, reactInstanceManager);
    ArgumentCaptor<CommandListenerAdapter> captor = ArgumentCaptor.forClass(CommandListenerAdapter.class);
    verify(rootPresenter).setRoot(eq(child1), eq(null), eq(uut.getDefaultOptions()), captor.capture(), eq(reactInstanceManager));
    assertThat(captor.getValue().getListener()).isEqualTo(listener);
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 8 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter 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 9 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter in project react-native-navigation by wix.

the class NavigatorTest method shouldCallOverlaysOnHostResumeWhenHostResumes.

@Test
public void shouldCallOverlaysOnHostResumeWhenHostResumes() {
    SimpleViewController child1 = spy(this.child1);
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.onHostResume();
    verify(overlayManager).onHostResume();
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 10 with CommandListenerAdapter

use of com.reactnativenavigation.react.CommandListenerAdapter 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

CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)121 BaseTest (com.reactnativenavigation.BaseTest)115 Test (org.junit.Test)115 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)22 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)19 Options (com.reactnativenavigation.options.Options)17 CommandListener (com.reactnativenavigation.react.CommandListener)16 Bool (com.reactnativenavigation.options.params.Bool)7 ModalOptions (com.reactnativenavigation.options.ModalOptions)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Text (com.reactnativenavigation.options.params.Text)4 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)3 FrameLayout (android.widget.FrameLayout)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 InOrder (org.mockito.InOrder)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Nullable (androidx.annotation.Nullable)1 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)1