Search in sources :

Example 21 with Options

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

the class ModalPresenter method showModal.

void showModal(ViewController<?> appearing, ViewController<?> disappearing, CommandListener listener) {
    if (modalsLayout == null) {
        listener.onError("Can not show modal before activity is created");
        return;
    }
    Options options = appearing.resolveCurrentOptions(defaultOptions);
    AnimationOptions enterAnimationOptions = options.animations.showModal.getEnter();
    appearing.setWaitForRender(enterAnimationOptions.waitForRender);
    modalsLayout.setVisibility(View.VISIBLE);
    modalsLayout.addView(appearing.getView(), matchParentLP());
    if (enterAnimationOptions.enabled.isTrueOrUndefined()) {
        if (enterAnimationOptions.shouldWaitForRender().isTrue()) {
            appearing.addOnAppearedListener(() -> modalAnimator.show(appearing, disappearing, options.animations.showModal, createListener(appearing, disappearing, listener)));
        } else {
            modalAnimator.show(appearing, disappearing, options.animations.showModal, createListener(appearing, disappearing, listener));
        }
    } else {
        if (enterAnimationOptions.waitForRender.isTrue()) {
            appearing.addOnAppearedListener(() -> onShowModalEnd(appearing, disappearing, listener));
        } else {
            onShowModalEnd(appearing, disappearing, listener);
        }
    }
}
Also used : Options(com.reactnativenavigation.options.Options) AnimationOptions(com.reactnativenavigation.options.AnimationOptions) AnimationOptions(com.reactnativenavigation.options.AnimationOptions)

Example 22 with Options

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

the class ParentControllerTest method resolveCurrentOptions_withDefaultOptions.

@Test
public void resolveCurrentOptions_withDefaultOptions() {
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    children.add(child1);
    uut.ensureViewIsCreated();
    Options defaultOptions = new Options();
    Options currentOptions = spy(new Options());
    ParentController<?> spy = spy(uut);
    Mockito.when(spy.resolveCurrentOptions()).thenReturn(currentOptions);
    spy.resolveCurrentOptions(defaultOptions);
    verify(currentOptions).withDefaultOptions(defaultOptions);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 23 with Options

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

the class ParentControllerTest method mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears.

@Test
public void mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears() {
    Options options = new Options();
    options.topBar.title.text = new Text("new title");
    ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
    children.add(child1);
    uut.ensureViewIsCreated();
    child1.ensureViewIsCreated();
    child1.onViewWillAppear();
    assertThat(uut.initialOptions.topBar.title.text.get()).isEqualTo(INITIAL_TITLE);
}
Also used : Options(com.reactnativenavigation.options.Options) Text(com.reactnativenavigation.options.params.Text) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 24 with Options

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

the class ModalPresenterTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    Activity activity = newActivity();
    ChildControllersRegistry childRegistry = new ChildControllersRegistry();
    root = spy(new SimpleViewController(activity, childRegistry, "root", new Options()));
    FrameLayout contentLayout = new FrameLayout(activity);
    FrameLayout rootLayout = new FrameLayout(activity);
    rootLayout.addView(root.getView());
    modalsLayout = new CoordinatorLayout(activity);
    contentLayout.addView(rootLayout);
    contentLayout.addView(modalsLayout);
    activity.setContentView(contentLayout);
    animator = spy(new ModalAnimator(activity));
    uut = new ModalPresenter(animator);
    uut.setModalsLayout(modalsLayout);
    uut.setRootLayout(rootLayout);
    modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
    modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) Options(com.reactnativenavigation.options.Options) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 25 with Options

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

the class ModalStackTest method dismissAllModals_optionsAreMergedOnTopModal.

@Test
public void dismissAllModals_optionsAreMergedOnTopModal() {
    uut.showModal(modal1, root, new CommandListenerAdapter());
    uut.showModal(modal2, root, new CommandListenerAdapter());
    uut.showModal(modal3, root, new CommandListenerAdapter());
    Options mergeOptions = new Options();
    uut.dismissAllModals(root, mergeOptions, new CommandListenerAdapter());
    verify(modal3).mergeOptions(mergeOptions);
    verify(modal1, times(0)).mergeOptions(mergeOptions);
    verify(modal2, times(0)).mergeOptions(mergeOptions);
}
Also used : TransitionAnimationOptions(com.reactnativenavigation.options.TransitionAnimationOptions) Options(com.reactnativenavigation.options.Options) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

Options (com.reactnativenavigation.options.Options)110 BaseTest (com.reactnativenavigation.BaseTest)57 Test (org.junit.Test)57 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)32 SideMenuOptions (com.reactnativenavigation.options.SideMenuOptions)19 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)18 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)16 Bool (com.reactnativenavigation.options.params.Bool)15 Text (com.reactnativenavigation.options.params.Text)15 OrientationOptions (com.reactnativenavigation.options.OrientationOptions)10 AnimationOptions (com.reactnativenavigation.options.AnimationOptions)9 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)9 FrameLayout (android.widget.FrameLayout)8 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)8 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)8 ComponentOptions (com.reactnativenavigation.options.ComponentOptions)6 TopBarOptions (com.reactnativenavigation.options.TopBarOptions)6 TopTabOptions (com.reactnativenavigation.options.TopTabOptions)6 TopTabsOptions (com.reactnativenavigation.options.TopTabsOptions)6 Activity (android.app.Activity)5