use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.
the class OptionsApplyingTest method reappliesOptionsOnMerge.
@Test
public void reappliesOptionsOnMerge() {
assertThat(stack.getTopBar().getTitle()).isEmpty();
stack.push(uut, new CommandListenerAdapter());
Options opts = new Options();
opts.topBar.title.text = new Text("the new title");
uut.mergeOptions(opts);
assertThat(stack.getTopBar().getTitle()).isEqualTo("the new title");
}
use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.
the class OptionsApplyingTest method beforeEach.
@Override
public void beforeEach() {
super.beforeEach();
activity = newActivity();
initialNavigationOptions = new Options();
view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
view.asView().setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, initialNavigationOptions, new Presenter(activity, new Options()), new ComponentPresenter(Options.EMPTY)) {
@Override
public boolean isViewShown() {
return true;
}
};
TopBarController topBarController = new TopBarController() {
@Override
protected TopBar createTopBar(Context context, StackLayout stackLayout) {
topBar = spy(super.createTopBar(context, stackLayout));
return topBar;
}
};
stack = TestUtils.newStackController(activity).setTopBarController(topBarController).build();
stack.ensureViewIsCreated();
stack.getView().layout(0, 0, 1000, 1000);
stack.getTopBar().layout(0, 0, 1000, 100);
activity.setContentView(stack.getView());
disablePushAnimation(uut);
}
use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.
the class OptionsApplyingTest method mergeNavigationOptionsUpdatesCurrentOptions.
@Test
public void mergeNavigationOptionsUpdatesCurrentOptions() {
assertThat(uut.options.topBar.title.text.get("")).isEmpty();
Options options = new Options();
options.topBar.title.text = new Text("new title");
uut.mergeOptions(options);
assertThat(uut.options.topBar.title.text.get()).isEqualTo("new title");
}
use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.
the class StackController method push.
public void push(ViewController<?> child, CommandListener listener) {
if (findController(child.getId()) != null) {
listener.onError("A stack can't contain two children with the same id: " + child.getId());
return;
}
final ViewController<?> toRemove = stack.peek();
if (size() > 0)
backButtonHelper.addToPushedChild(child);
child.setParentController(this);
stack.push(child.getId(), child);
if (!isViewCreated())
return;
Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions());
addChildToStack(child, resolvedOptions);
if (toRemove != null) {
StackAnimationOptions animation = resolvedOptions.animations.push;
if (animation.enabled.isTrueOrUndefined()) {
animator.push(child, toRemove, resolvedOptions, presenter.getAdditionalPushAnimations(this, child, resolvedOptions), () -> onPushAnimationComplete(child, toRemove, listener));
} else {
onPushAnimationComplete(child, toRemove, listener);
}
} else {
listener.onSuccess(child.getId());
}
}
use of com.reactnativenavigation.options.Options 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());
}
}
Aggregations