Search in sources :

Example 76 with Options

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

the class StackPresenter method getTopBarTopMargin.

private int getTopBarTopMargin(StackController stack, ViewController<?> child) {
    Options withDefault = stack.resolveChildOptions(child).withDefaultOptions(defaultOptions);
    int topMargin = UiUtils.dpToPx(activity, withDefault.topBar.topMargin.get(0));
    int statusBarInset = withDefault.statusBar.visible.isTrueOrUndefined() && !withDefault.statusBar.drawBehind.isTrue() ? SystemUiUtils.getStatusBarHeight(child.getActivity()) : 0;
    return topMargin + statusBarInset;
}
Also used : TopTabOptions(com.reactnativenavigation.options.TopTabOptions) ComponentOptions(com.reactnativenavigation.options.ComponentOptions) ButtonOptions(com.reactnativenavigation.options.ButtonOptions) TopBarOptions(com.reactnativenavigation.options.TopBarOptions) AnimationOptions(com.reactnativenavigation.options.AnimationOptions) TopTabsOptions(com.reactnativenavigation.options.TopTabsOptions) OrientationOptions(com.reactnativenavigation.options.OrientationOptions) Options(com.reactnativenavigation.options.Options)

Example 77 with Options

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

the class Presenter method onConfigurationChanged.

public void onConfigurationChanged(ViewController controller, Options options) {
    Options withDefault = options.withDefaultOptions(defaultOptions);
    setNavigationBarBackgroundColor(withDefault.navigationBar);
    setStatusBarBackgroundColor(withDefault.statusBar);
    setTextColorScheme(withDefault.statusBar);
    applyBackgroundColor(controller, withDefault);
}
Also used : NavigationBarOptions(com.reactnativenavigation.options.NavigationBarOptions) OrientationOptions(com.reactnativenavigation.options.OrientationOptions) Options(com.reactnativenavigation.options.Options) StatusBarOptions(com.reactnativenavigation.options.StatusBarOptions)

Example 78 with Options

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

the class Presenter method mergeOptions.

public void mergeOptions(ViewController<?> viewController, Options options) {
    final Options withDefaults = viewController.resolveCurrentOptions().copy().mergeWith(options).withDefaultOptions(defaultOptions);
    mergeStatusBarOptions(viewController.getView(), withDefaults.statusBar);
    mergeNavigationBarOptions(withDefaults.navigationBar);
    applyLayoutInsetsOnMostTopParent(viewController, withDefaults.layout.getInsets());
}
Also used : NavigationBarOptions(com.reactnativenavigation.options.NavigationBarOptions) OrientationOptions(com.reactnativenavigation.options.OrientationOptions) Options(com.reactnativenavigation.options.Options) StatusBarOptions(com.reactnativenavigation.options.StatusBarOptions)

Example 79 with Options

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

the class ModalPresenter method dismissModal.

void dismissModal(ViewController<?> toDismiss, @Nullable ViewController<?> toAdd, ViewController<?> root, CommandListener listener) {
    if (modalsLayout == null) {
        listener.onError("Can not dismiss modal before activity is created");
        return;
    }
    if (toAdd != null) {
        toAdd.attachView(toAdd == root ? rootLayout : modalsLayout, 0);
        toAdd.onViewDidAppear();
    }
    Options options = toDismiss.resolveCurrentOptions(defaultOptions);
    if (options.animations.dismissModal.getExit().enabled.isTrueOrUndefined()) {
        modalAnimator.dismiss(toAdd, toDismiss, options.animations.dismissModal, new ScreenAnimationListener() {

            @Override
            public void onEnd() {
                onDismissEnd(toDismiss, listener);
            }
        });
    } else {
        onDismissEnd(toDismiss, listener);
    }
}
Also used : Options(com.reactnativenavigation.options.Options) AnimationOptions(com.reactnativenavigation.options.AnimationOptions) ScreenAnimationListener(com.reactnativenavigation.utils.ScreenAnimationListener)

Example 80 with Options

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

the class PresenterTest method shouldMergeInsetsOnTopMostParent.

@Test
public void shouldMergeInsetsOnTopMostParent() {
    final ViewGroup spy = Mockito.mock(ViewGroup.class);
    Mockito.when(spy.getLayoutParams()).thenReturn(new ViewGroup.LayoutParams(0, 0));
    Mockito.when(controller.getView()).thenReturn(spy);
    Mockito.when(controller.resolveCurrentOptions()).thenReturn(Options.EMPTY);
    Options options = new Options();
    options.layout.setInsets(new LayoutInsets(1, 2, 3, 4));
    uut.mergeOptions(controller, options);
    verify(parentView).setPadding(2, 1, 4, 3);
}
Also used : Options(com.reactnativenavigation.options.Options) ViewGroup(android.view.ViewGroup) LayoutInsets(com.reactnativenavigation.options.layout.LayoutInsets) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

Options (com.reactnativenavigation.options.Options)110 BaseTest (com.reactnativenavigation.BaseTest)57 Test (org.junit.Test)57 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)32 SideMenuOptions (com.reactnativenavigation.options.SideMenuOptions)19 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)18 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)16 Bool (com.reactnativenavigation.options.params.Bool)15 Text (com.reactnativenavigation.options.params.Text)15 OrientationOptions (com.reactnativenavigation.options.OrientationOptions)10 AnimationOptions (com.reactnativenavigation.options.AnimationOptions)9 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)9 FrameLayout (android.widget.FrameLayout)8 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)8 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)8 ComponentOptions (com.reactnativenavigation.options.ComponentOptions)6 TopBarOptions (com.reactnativenavigation.options.TopBarOptions)6 TopTabOptions (com.reactnativenavigation.options.TopTabOptions)6 TopTabsOptions (com.reactnativenavigation.options.TopTabsOptions)6 Activity (android.app.Activity)5