Search in sources :

Example 1 with StackBehaviour

use of com.reactnativenavigation.views.stack.StackBehaviour in project react-native-navigation by wix.

the class StackController method addInitialChild.

private void addInitialChild(StackLayout stackLayout) {
    if (isEmpty())
        return;
    ViewController<?> childController = peek();
    ViewGroup child = childController.getView();
    setChildId(child);
    childController.addOnAppearedListener(this::startChildrenBellowTopChild);
    stackLayout.addView(child, 0, matchParentWithBehaviour(new StackBehaviour(this)));
    presenter.applyInitialChildLayoutOptions(resolveCurrentOptions());
}
Also used : StackBehaviour(com.reactnativenavigation.views.stack.StackBehaviour) ViewGroup(android.view.ViewGroup)

Example 2 with StackBehaviour

use of com.reactnativenavigation.views.stack.StackBehaviour in project react-native-navigation by wix.

the class StackController method pop.

public void pop(Options mergeOptions, CommandListener listener) {
    if (!canPop()) {
        listener.onError("Nothing to pop");
        return;
    }
    peek().mergeOptions(mergeOptions);
    Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions());
    final ViewController<?> disappearing = stack.pop();
    if (!isViewCreated())
        return;
    final ViewController<?> appearing = stack.peek();
    disappearing.onViewWillDisappear();
    ViewGroup appearingView = appearing.getView();
    if (appearingView.getLayoutParams() == null) {
        appearingView.setLayoutParams(matchParentWithBehaviour(new StackBehaviour(this)));
    }
    if (appearingView.getParent() == null) {
        getView().addView(appearingView, 0);
    }
    if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) {
        Options appearingOptions = resolveChildOptions(appearing).withDefaultOptions(presenter.getDefaultOptions());
        animator.pop(appearing, disappearing, disappearingOptions, presenter.getAdditionalPopAnimations(appearingOptions, disappearingOptions), () -> finishPopping(appearing, disappearing, listener));
    } else {
        finishPopping(appearing, disappearing, listener);
    }
}
Also used : ButtonOptions(com.reactnativenavigation.options.ButtonOptions) StackAnimationOptions(com.reactnativenavigation.options.StackAnimationOptions) Options(com.reactnativenavigation.options.Options) StackBehaviour(com.reactnativenavigation.views.stack.StackBehaviour) ViewGroup(android.view.ViewGroup)

Aggregations

ViewGroup (android.view.ViewGroup)2 StackBehaviour (com.reactnativenavigation.views.stack.StackBehaviour)2 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)1 Options (com.reactnativenavigation.options.Options)1 StackAnimationOptions (com.reactnativenavigation.options.StackAnimationOptions)1