Search in sources :

Example 6 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter 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 7 with Presenter

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

the class PresenterTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    controller = mock(ViewController.class);
    parentView = mock(ViewGroup.class);
    parentController = Mocks.INSTANCE.parentController(null, parentView);
    controller.setParentController((ParentController) parentController);
    Mockito.when(controller.getTopMostParent()).thenReturn(parentController);
    uut = new Presenter(activity, Options.EMPTY);
}
Also used : ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) ViewGroup(android.view.ViewGroup) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)

Example 8 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter 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 9 with Presenter

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

the class LayoutFactory method createSideMenuRoot.

private ViewController<?> createSideMenuRoot(LayoutNode node) {
    SideMenuController sideMenuController = new SideMenuController(activity, childRegistry, node.id, parseOptions(node.getOptions()), new SideMenuPresenter(), new Presenter(activity, defaultOptions));
    ViewController<?> childControllerCenter = null, childControllerLeft = null, childControllerRight = null;
    for (LayoutNode child : node.children) {
        switch(child.type) {
            case SideMenuCenter:
                childControllerCenter = create(child);
                childControllerCenter.setParentController(sideMenuController);
                break;
            case SideMenuLeft:
                childControllerLeft = create(child);
                childControllerLeft.setParentController(sideMenuController);
                break;
            case SideMenuRight:
                childControllerRight = create(child);
                childControllerRight.setParentController(sideMenuController);
                break;
            default:
                throw new IllegalArgumentException("Invalid node type in sideMenu: " + node.type);
        }
    }
    if (childControllerCenter != null) {
        sideMenuController.setCenterController(childControllerCenter);
    }
    if (childControllerLeft != null) {
        sideMenuController.setLeftController(childControllerLeft);
    }
    if (childControllerRight != null) {
        sideMenuController.setRightController(childControllerRight);
    }
    return sideMenuController;
}
Also used : SideMenuPresenter(com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter) SideMenuController(com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuController) 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)

Example 10 with Presenter

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

the class LayoutFactory method createComponent.

private ViewController<?> createComponent(LayoutNode node) {
    String id = node.id;
    String name = node.data.optString("name");
    return new ComponentViewController(activity, childRegistry, id, name, new ComponentViewCreator(reactInstanceManager), parseOptions(node.getOptions()), new Presenter(activity, defaultOptions), new ComponentPresenter(defaultOptions));
}
Also used : 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) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) ExternalComponentViewController(com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController) ComponentViewCreator(com.reactnativenavigation.views.component.ComponentViewCreator) ExternalComponentPresenter(com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)

Aggregations

Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)13 Options (com.reactnativenavigation.options.Options)8 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)7 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)6 ComponentViewController (com.reactnativenavigation.viewcontrollers.component.ComponentViewController)5 ViewController (com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController)5 BottomTabPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter)4 BottomTabsPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter)4 ExternalComponentPresenter (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter)4 SideMenuPresenter (com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter)4 StackPresenter (com.reactnativenavigation.viewcontrollers.stack.StackPresenter)4 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)3 ExternalComponentViewController (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController)3 TestComponentLayout (com.reactnativenavigation.mocks.TestComponentLayout)2 TestReactView (com.reactnativenavigation.mocks.TestReactView)2 Bool (com.reactnativenavigation.options.params.Bool)2 Text (com.reactnativenavigation.options.params.Text)2 TopTabsLayoutCreator (com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator)2 ArrayList (java.util.ArrayList)2 Activity (android.app.Activity)1