Search in sources :

Example 1 with ViewController

use of com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController in project react-native-navigation by wix.

the class LayoutFactory method createTopTabs.

private ViewController<?> createTopTabs(LayoutNode node) {
    final List<ViewController<?>> tabs = new ArrayList<>();
    for (int i = 0; i < node.children.size(); i++) {
        ViewController<?> tabController = create(node.children.get(i));
        Options options = parseOptions(node.children.get(i).getOptions());
        options.setTopTabIndex(i);
        tabs.add(tabController);
    }
    return new TopTabsController(activity, childRegistry, node.id, tabs, new TopTabsLayoutCreator(activity, tabs), parseOptions(node.getOptions()), new Presenter(activity, defaultOptions));
}
Also used : TopTabsLayoutCreator(com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator) 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) ArrayList(java.util.ArrayList) TopTabsController(com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController)

Example 2 with ViewController

use of com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController in project react-native-navigation by wix.

the class TopTabsViewControllerTest method createTabsControllers.

private List<ViewController<?>> createTabsControllers(Activity activity, List<Options> tabOptions) {
    List<ViewController<?>> tabControllers = new ArrayList<>(SIZE);
    for (int i = 0; i < SIZE; i++) {
        ComponentViewController viewController = new ComponentViewController(activity, childRegistry, "idTab" + i, "theComponentName", new TestComponentViewCreator(), tabOptions.get(i), new Presenter(activity, new Options()), new ComponentPresenter(Options.EMPTY));
        tabControllers.add(spy(viewController));
    }
    return tabControllers;
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) TestComponentViewCreator(com.reactnativenavigation.mocks.TestComponentViewCreator) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) ArrayList(java.util.ArrayList) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)

Example 3 with ViewController

use of com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController in project react-native-navigation by wix.

the class NavigationModule method setStackRoot.

@ReactMethod
public void setStackRoot(String commandId, String onComponentId, ReadableArray children, Promise promise) {
    handle(() -> {
        ArrayList<ViewController<?>> _children = new ArrayList<>();
        for (int i = 0; i < children.size(); i++) {
            final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(children.getMap(i)));
            _children.add(layoutFactory.create(layoutTree));
        }
        navigator().setStackRoot(onComponentId, _children, new NativeCommandListener("setStackRoot", commandId, promise, eventEmitter, now));
    });
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) ArrayList(java.util.ArrayList) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 4 with ViewController

use of com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController in project react-native-navigation by wix.

the class SideMenuControllerTest method onViewAppeared.

@Test
public void onViewAppeared() {
    ViewController left = spy(this.left);
    ViewGroup leftView = spy(left.getView());
    when(left.findController(leftView)).thenReturn(left);
    Mockito.doReturn(leftView).when(left).getView();
    ViewController right = spy(this.right);
    ViewGroup rightView = spy(right.getView());
    when(right.findController(rightView)).thenReturn(right);
    Mockito.doReturn(rightView).when(right).getView();
    setLeftRight(left, right);
    uut.onViewWillAppear();
    verify(leftView).requestLayout();
    verify(rightView).requestLayout();
}
Also used : ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController) ViewGroup(android.view.ViewGroup) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 5 with ViewController

use of com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController in project react-native-navigation by wix.

the class BottomTabsAttacherTest method beforeEach.

@Override
public void beforeEach() {
    mode = Mockito.mock(AttachMode.class);
    List<ViewController<?>> tabs = Arrays.asList(mock(ViewController.class), mock(ViewController.class));
    uut = new BottomTabsAttacher(tabs, Mockito.mock(BottomTabsPresenter.class), defaultOptions);
    uut.attachStrategy = mode;
}
Also used : TabsAttachMode(com.reactnativenavigation.options.TabsAttachMode) AttachMode(com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.modes.AttachMode) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) BottomTabsAttacher(com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher)

Aggregations

ViewController (com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController)10 Options (com.reactnativenavigation.options.Options)4 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)4 BaseTest (com.reactnativenavigation.BaseTest)3 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)3 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)3 ComponentViewController (com.reactnativenavigation.viewcontrollers.component.ComponentViewController)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 FrameLayout (android.widget.FrameLayout)2 LayoutNode (com.reactnativenavigation.options.LayoutNode)2 BottomTabPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter)2 BottomTabsPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter)2 BottomTabsAttacher (com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher)2 ExternalComponentPresenter (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter)2 ExternalComponentViewController (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController)2 SideMenuPresenter (com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter)2 StackPresenter (com.reactnativenavigation.viewcontrollers.stack.StackPresenter)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1