use of com.reactnativenavigation.react.CommandListener in project react-native-navigation by wix.
the class OverlayManagerTest method dismiss_rejectIfOverlayNotFound.
@Test
public void dismiss_rejectIfOverlayNotFound() {
CommandListener listener = spy(new CommandListenerAdapter());
uut.dismiss(overlayContainer, overlay1.getId(), listener);
verify(listener, times(1)).onError(any());
}
use of com.reactnativenavigation.react.CommandListener in project react-native-navigation by wix.
the class StackController method setRoot.
public void setRoot(@Size(min = 1) List<ViewController<?>> children, CommandListener listener) {
if (!isViewCreated()) {
setChildren(children);
return;
}
animator.cancelPushAnimations();
final ViewController<?> toRemove = stack.peek();
IdStack<?> stackToDestroy = stack;
stack = new IdStack<>();
ViewController<?> child = requireLast(children);
if (children.size() == 1) {
backButtonHelper.clear(child);
} else {
backButtonHelper.addToPushedChild(child);
}
child.setParentController(this);
stack.push(child.getId(), child);
Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions());
addChildToStack(child, resolvedOptions);
CommandListener listenerAdapter = new CommandListenerAdapter() {
@Override
public void onSuccess(String childId) {
if (child.isViewShown())
child.onViewDidAppear();
destroyStack(stackToDestroy);
if (children.size() > 1) {
for (int i = 0; i < children.size() - 1; i++) {
stack.set(children.get(i).getId(), children.get(i), i);
children.get(i).setParentController(StackController.this);
if (i == 0) {
backButtonHelper.clear(children.get(i));
} else {
backButtonHelper.addToPushedChild(children.get(i));
}
}
startChildrenBellowTopChild();
}
listener.onSuccess(childId);
}
};
if (toRemove != null && resolvedOptions.animations.setStackRoot.enabled.isTrueOrUndefined()) {
if (resolvedOptions.animations.setStackRoot.waitForRender.isTrue()) {
child.getView().setAlpha(0);
child.addOnAppearedListener(() -> animator.setRoot(child, toRemove, resolvedOptions, presenter.getAdditionalSetRootAnimations(this, child, resolvedOptions), () -> listenerAdapter.onSuccess(child.getId())));
} else {
animator.setRoot(child, toRemove, resolvedOptions, presenter.getAdditionalSetRootAnimations(this, child, resolvedOptions), () -> listenerAdapter.onSuccess(child.getId()));
}
} else {
listenerAdapter.onSuccess(child.getId());
}
}
use of com.reactnativenavigation.react.CommandListener in project react-native-navigation by wix.
the class ModalPresenterTest method showModal_noAnimation.
@Test
public void showModal_noAnimation() {
disableShowModalAnimation(modal1);
CommandListener listener = spy(new CommandListenerAdapter() {
@Override
public void onSuccess(String childId) {
Shadows.shadowOf(Looper.getMainLooper()).idle();
assertThat(modal1.getView().getParent()).isEqualTo(modalsLayout);
verify(modal1).onViewWillAppear();
}
});
uut.showModal(modal1, root, listener);
verify(animator, never()).show(eq(modal1), eq(root), eq(modal1.options.animations.showModal), any());
verify(listener).onSuccess(MODAL_ID_1);
}
use of com.reactnativenavigation.react.CommandListener in project react-native-navigation by wix.
the class ModalStackTest method dismissModal.
@Test
public void dismissModal() {
uut.showModal(modal1, root, new CommandListenerAdapter());
CommandListener listener = spy(new CommandListenerAdapter());
uut.dismissModal(modal1.getId(), root, listener);
assertThat(findModal(modal1.getId())).isNull();
verify(presenter).dismissModal(eq(modal1), eq(root), eq(root), any());
verify(listener).onSuccess(modal1.getId());
}
use of com.reactnativenavigation.react.CommandListener in project react-native-navigation by wix.
the class OverlayManagerTest method dismiss.
@Test
public void dismiss() {
uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
assertThat(uut.size()).isOne();
CommandListener listener = spy(new CommandListenerAdapter());
uut.dismiss(overlayContainer, overlay1.getId(), listener);
assertThat(uut.size()).isZero();
verify(listener, times(1)).onSuccess(OVERLAY_ID_1);
verify(overlay1, times(1)).destroy();
}
Aggregations