Search in sources :

Example 56 with CommandListenerAdapter

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

the class FloatingActionButtonTest method hideOnPush.

@Test
public void hideOnPush() {
    stackController.push(childFab, new CommandListenerAdapter());
    childFab.onViewWillAppear();
    assertThat(hasFab()).isTrue();
    stackController.push(childNoFab, new CommandListenerAdapter());
    childNoFab.onViewWillAppear();
    assertThat(hasFab()).isFalse();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 57 with CommandListenerAdapter

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

the class FloatingActionButtonTest method hideOnPop.

@Test
public void hideOnPop() {
    disablePushAnimation(childNoFab, childFab);
    stackController.push(childNoFab, new CommandListenerAdapter());
    stackController.push(childFab, new CommandListenerAdapter());
    childFab.onViewWillAppear();
    assertThat(hasFab()).isTrue();
    stackController.pop(Options.EMPTY, new CommandListenerAdapter());
    childNoFab.onViewWillAppear();
    assertThat(hasFab()).isFalse();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 58 with CommandListenerAdapter

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

the class ModalPresenterTest method showModal_resolvesDefaultOptions.

@Test
public void showModal_resolvesDefaultOptions() throws JSONException {
    Options defaultOptions = new Options();
    JSONObject disabledShowModalAnimation = TransitionAnimationOptionsTestKt.newModalAnimationJson(false);
    defaultOptions.animations.showModal = TransitionAnimationOptionsKt.parseTransitionAnimationOptions(disabledShowModalAnimation);
    uut.setDefaultOptions(defaultOptions);
    uut.showModal(modal1, root, new CommandListenerAdapter());
    verifyNoInteractions(animator);
}
Also used : Options(com.reactnativenavigation.options.Options) JSONObject(org.json.JSONObject) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 59 with CommandListenerAdapter

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

the class ModalStack method dismissModal.

public boolean dismissModal(String componentId, @Nullable ViewController<?> root, CommandListener listener) {
    ViewController<?> toDismiss = findModalByComponentId(componentId);
    if (toDismiss != null) {
        boolean isDismissingTopModal = isTop(toDismiss);
        modals.remove(toDismiss);
        @Nullable ViewController<?> toAdd = isEmpty() ? root : isDismissingTopModal ? get(size() - 1) : null;
        if (isDismissingTopModal) {
            if (toAdd == null) {
                listener.onError("Could not dismiss modal");
                return false;
            }
        }
        presenter.dismissModal(toDismiss, toAdd, root, new CommandListenerAdapter(listener) {

            @Override
            public void onSuccess(String childId) {
                eventEmitter.emitModalDismissed(toDismiss.getId(), toDismiss.getCurrentComponentName(), 1);
                super.onSuccess(toDismiss.getId());
            }
        });
        return true;
    } else {
        listener.onError("Nothing to dismiss");
        return false;
    }
}
Also used : Nullable(androidx.annotation.Nullable) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter)

Example 60 with CommandListenerAdapter

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

the class BackButtonHelperTest method addToChild_doesNotAddIfBackButtonHidden.

@Test
public void addToChild_doesNotAddIfBackButtonHidden() {
    disablePushAnimation(child1, child2);
    stack.push(child1, new CommandListenerAdapter());
    child2.options.topBar.buttons.back.visible = new Bool(false);
    stack.push(child2, new CommandListenerAdapter());
    verify(child2, times(0)).mergeOptions(any());
}
Also used : Bool(com.reactnativenavigation.options.params.Bool) 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