use of com.reactnativenavigation.options.AnimationOptions 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);
}
}
}
use of com.reactnativenavigation.options.AnimationOptions in project react-native-navigation by wix.
the class RootPresenter method setRoot.
public void setRoot(ViewController appearingRoot, ViewController<?> disappearingRoot, Options defaultOptions, CommandListener listener, ReactInstanceManager reactInstanceManager) {
layoutDirectionApplier.apply(appearingRoot, defaultOptions, reactInstanceManager);
rootLayout.addView(appearingRoot.getView(), matchParentWithBehaviour(new BehaviourDelegate(appearingRoot)));
Options options = appearingRoot.resolveCurrentOptions(defaultOptions);
AnimationOptions enter = options.animations.setRoot.getEnter();
appearingRoot.setWaitForRender(enter.waitForRender);
if (enter.waitForRender.isTrue()) {
appearingRoot.getView().setAlpha(0);
appearingRoot.addOnAppearedListener(() -> {
if (appearingRoot.isDestroyed()) {
listener.onError("Could not set root - Waited for the view to become visible but it was destroyed");
} else {
appearingRoot.getView().setAlpha(1);
animateSetRootAndReportSuccess(appearingRoot, disappearingRoot, listener, options);
}
});
} else {
animateSetRootAndReportSuccess(appearingRoot, disappearingRoot, listener, options);
}
}
use of com.reactnativenavigation.options.AnimationOptions in project react-native-navigation by wix.
the class StackPresenter method mergeTopBarOptions.
private void mergeTopBarOptions(TopBarOptions resolveOptions, Options toMerge, StackController stack, ViewController<?> child) {
TopBarOptions topBarOptions = toMerge.topBar;
final View component = child.getView();
if (toMerge.layout.direction.hasValue())
topBar.setLayoutDirection(toMerge.layout.direction);
if (topBarOptions.height.hasValue())
topBar.setHeight(topBarOptions.height.get());
if (topBarOptions.elevation.hasValue())
topBar.setElevation(topBarOptions.elevation.get());
if (topBarOptions.topMargin.hasValue() && topBar.getLayoutParams() instanceof MarginLayoutParams) {
((MarginLayoutParams) topBar.getLayoutParams()).topMargin = UiUtils.dpToPx(activity, topBarOptions.topMargin.get());
}
Options childOptions = stack.resolveChildOptions(child).mergeWith(toMerge).withDefaultOptions(defaultOptions);
mergeStatusBarDrawBehindOptions(resolveOptions, childOptions);
if (topBarOptions.title.height.hasValue())
topBar.setTitleHeight(topBarOptions.title.height.get());
if (topBarOptions.title.topMargin.hasValue())
topBar.setTitleTopMargin(topBarOptions.title.topMargin.get());
if (topBarOptions.animateLeftButtons.hasValue())
topBar.animateLeftButtons(topBarOptions.animateLeftButtons.isTrue());
if (topBarOptions.animateRightButtons.hasValue())
topBar.animateRightButtons(topBarOptions.animateRightButtons.isTrue());
if (topBarOptions.title.component.hasValue()) {
TitleBarReactViewController controller = findTitleComponent(topBarOptions.title.component);
if (controller == null) {
controller = new TitleBarReactViewController(activity, titleViewCreator, topBarOptions.title.component);
perform(titleControllers.put(component, controller), ViewController::destroy);
}
topBarController.setTitleComponent(controller);
topBarController.alignTitleComponent(topBarOptions.title.component.alignment);
} else if (topBarOptions.title.text.hasValue()) {
perform(titleControllers.remove(component), ViewController::destroy);
topBar.setTitle(topBarOptions.title.text.get());
topBarController.alignTitleComponent(topBarOptions.title.alignment);
}
if (resolveOptions.title.alignment != Alignment.Default) {
topBarController.alignTitleComponent(resolveOptions.title.alignment);
}
if (resolveOptions.title.color.hasValue())
topBar.setTitleTextColor(resolveOptions.title.color.get());
if (resolveOptions.title.fontSize.hasValue())
topBar.setTitleFontSize(resolveOptions.title.fontSize.get());
if (resolveOptions.title.font.hasValue())
topBar.setTitleTypeface(typefaceLoader, resolveOptions.title.font);
if (resolveOptions.subtitle.text.hasValue()) {
topBar.setSubtitle(resolveOptions.subtitle.text.get());
topBar.setSubtitleAlignment(resolveOptions.subtitle.alignment);
}
if (resolveOptions.subtitle.color.hasValue())
topBar.setSubtitleColor(resolveOptions.subtitle.color.get());
if (resolveOptions.subtitle.fontSize.hasValue()) {
topBar.setSubtitleFontSize(resolveOptions.subtitle.fontSize.get());
}
if (resolveOptions.subtitle.font.hasValue()) {
topBar.setSubtitleTypeface(typefaceLoader, resolveOptions.subtitle.font);
}
if (topBarOptions.background.color.hasValue())
topBar.setBackgroundColor(topBarOptions.background.color.get());
if (topBarOptions.background.component.hasValue()) {
if (backgroundControllers.containsKey(component)) {
topBar.setBackgroundComponent(Objects.requireNonNull(backgroundControllers.get(component)).getView());
} else {
TopBarBackgroundViewController controller = new TopBarBackgroundViewController(activity, topBarBackgroundViewCreator);
backgroundControllers.put(component, controller);
controller.setComponent(topBarOptions.background.component);
controller.getView().setLayoutParams(new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
topBar.setBackgroundComponent(controller.getView());
}
}
if (topBarOptions.testId.hasValue())
topBar.setTestId(topBarOptions.testId.get());
if (topBarOptions.visible.isFalse()) {
if (topBarOptions.animate.isTrueOrUndefined()) {
topBarController.hideAnimate(new AnimationOptions(), getTopBarTranslationAnimationDelta(stack, child));
} else {
topBarController.hide();
}
}
if (topBarOptions.visible.isTrue()) {
if (topBarOptions.animate.isTrueOrUndefined()) {
topBarController.showAnimate(new AnimationOptions(), getTopBarTranslationAnimationDelta(stack, child));
} else {
topBarController.show();
}
}
if (topBarOptions.hideOnScroll.isTrue() && component instanceof IReactView) {
topBar.enableCollapse(((IReactView) component).getScrollEventListener());
}
if (topBarOptions.hideOnScroll.isFalse()) {
topBar.disableCollapse();
}
}
use of com.reactnativenavigation.options.AnimationOptions in project react-native-navigation by wix.
the class RootPresenter method animateSetRootAndReportSuccess.
private void animateSetRootAndReportSuccess(ViewController root, ViewController disappearingRoot, CommandListener listener, Options options) {
AnimationOptions exit = options.animations.setRoot.getExit();
AnimationOptions enter = options.animations.setRoot.getEnter();
if ((enter.enabled.isTrueOrUndefined() && enter.hasAnimation()) || (disappearingRoot != null && exit.enabled.isTrueOrUndefined() && exit.hasAnimation())) {
animator.setRoot(root, disappearingRoot, options.animations.setRoot, () -> {
listener.onSuccess(root.getId());
return Unit.INSTANCE;
});
} else {
listener.onSuccess(root.getId());
}
}
Aggregations