Search in sources :

Example 11 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class ExternalComponentViewControllerTest method beforeEach.

@Override
public void beforeEach() {
    componentCreator = spy(new FragmentCreatorMock());
    activity = newActivity();
    ec = createExternalComponent();
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    emitter = Mockito.mock(EventEmitter.class);
    childRegistry = new ChildControllersRegistry();
    uut = spy(new ExternalComponentViewController(activity, childRegistry, "fragmentId", new Presenter(activity, Options.EMPTY), ec, componentCreator, reactInstanceManager, emitter, new ExternalComponentPresenter(), new Options()));
}
Also used : Options(com.reactnativenavigation.options.Options) ReactInstanceManager(com.facebook.react.ReactInstanceManager) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Example 12 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class BottomTabPresenterTest method createBottomTabs.

private void createBottomTabs(Options tab1Options, Options tab2Options, Options tab3Options) {
    childRegistry = new ChildControllersRegistry();
    bottomTabs = Mockito.mock(BottomTabs.class);
    child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tab1Options));
    child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tab2Options));
    child3 = spy(new SimpleViewController(activity, childRegistry, "child2", tab3Options));
    tabs = Arrays.asList(child1, child2, child3);
    uut = new BottomTabPresenter(activity, tabs, ImageLoaderMock.mock(), new TypefaceLoaderMock(), new Options());
    uut.bindView(bottomTabs);
    uut.setDefaultOptions(new Options());
}
Also used : BottomTabs(com.reactnativenavigation.views.bottomtabs.BottomTabs) Options(com.reactnativenavigation.options.Options) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) TypefaceLoaderMock(com.reactnativenavigation.mocks.TypefaceLoaderMock)

Example 13 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class NavigationActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) {
        return;
    }
    addDefaultSplashLayout();
    navigator = new Navigator(this, new ChildControllersRegistry(), new ModalStack(this), new OverlayManager(), new RootPresenter());
    navigator.bindViews();
    getReactGateway().onActivityCreated(this);
}
Also used : OverlayManager(com.reactnativenavigation.viewcontrollers.overlay.OverlayManager) ModalStack(com.reactnativenavigation.viewcontrollers.modal.ModalStack) Navigator(com.reactnativenavigation.viewcontrollers.navigator.Navigator) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) RootPresenter(com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter)

Example 14 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class ParentControllerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    children = new ArrayList<>();
    Options initialOptions = new Options();
    initialOptions.topBar.title.text = new Text(INITIAL_TITLE);
    presenter = spy(new Presenter(activity, new Options()));
    uut = spy(new ParentController<ViewGroup>(activity, childRegistry, "uut", presenter, initialOptions) {

        @Override
        public ViewController<?> getCurrentChild() {
            return children.get(0);
        }

        @NonNull
        @Override
        public ViewGroup createView() {
            FrameLayout layout = new FrameLayout(activity);
            for (ViewController<?> child : children) {
                child.setParentController(this);
                layout.addView(child.getView());
            }
            return layout;
        }

        @Override
        public void sendOnNavigationButtonPressed(String buttonId) {
        }

        @NonNull
        @Override
        public Collection<ViewController<?>> getChildControllers() {
            return children;
        }
    });
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) FrameLayout(android.widget.FrameLayout) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) Text(com.reactnativenavigation.options.params.Text)

Example 15 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class NavigatorTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    childRegistry = new ChildControllersRegistry();
    eventEmitter = Mockito.mock(EventEmitter.class);
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    overlayManager = spy(new OverlayManager());
    imageLoaderMock = ImageLoaderMock.mock();
    activityController = newActivityController(TestActivity.class);
    activity = activityController.create().get();
    modalStack = spy(new ModalStack(activity));
    rootPresenter = spy(new RootPresenter());
    modalStack.setEventEmitter(Mockito.mock(EventEmitter.class));
    uut = new Navigator(activity, childRegistry, modalStack, overlayManager, rootPresenter);
    activity.setNavigator(uut);
    ViewController<?> initialChild = new SimpleViewController(activity, childRegistry, "initialChild", Options.EMPTY);
    parentController = newStack(initialChild);
    parentVisibilityListener = spy(new ViewController.ViewVisibilityListener() {

        @Override
        public boolean onViewAppeared(View view) {
            return false;
        }

        @Override
        public boolean onViewDisappear(View view) {
            return false;
        }
    });
    parentController.setViewVisibilityListener(parentVisibilityListener);
    child1 = new SimpleViewController(activity, childRegistry, "child1", tabOptions);
    child2 = new SimpleViewController(activity, childRegistry, "child2", tabOptions);
    child3 = new SimpleViewController(activity, childRegistry, "child3", tabOptions);
    child4 = new SimpleViewController(activity, childRegistry, "child4", tabOptions);
    child5 = new SimpleViewController(activity, childRegistry, "child5", tabOptions);
    uut.bindViews();
    activityController.visible();
    activityController.postCreate(Bundle.EMPTY);
    idleMainLooper();
}
Also used : OverlayManager(com.reactnativenavigation.viewcontrollers.overlay.OverlayManager) ModalStack(com.reactnativenavigation.viewcontrollers.modal.ModalStack) ReactInstanceManager(com.facebook.react.ReactInstanceManager) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TestActivity(com.reactnativenavigation.TestActivity) RootPresenter(com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) View(android.view.View)

Aggregations

ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)19 Options (com.reactnativenavigation.options.Options)16 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)9 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)6 Activity (android.app.Activity)4 FrameLayout (android.widget.FrameLayout)4 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)4 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)3 ReactInstanceManager (com.facebook.react.ReactInstanceManager)3 Context (android.content.Context)2 View (android.view.View)2 TestComponentLayout (com.reactnativenavigation.mocks.TestComponentLayout)2 TestReactView (com.reactnativenavigation.mocks.TestReactView)2 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)2 Bool (com.reactnativenavigation.options.params.Bool)2 Text (com.reactnativenavigation.options.params.Text)2 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)2 ModalStack (com.reactnativenavigation.viewcontrollers.modal.ModalStack)2 OverlayManager (com.reactnativenavigation.viewcontrollers.overlay.OverlayManager)2 TopBarController (com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)2