Search in sources :

Example 6 with Options

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

the class StackPresenter method applyChildOptions.

public void applyChildOptions(Options currentChildOptions, StackController stack, ViewController<?> child) {
    Options finalChildOptions = currentChildOptions.copy().withDefaultOptions(defaultOptions);
    applyOrientation(finalChildOptions.layout.orientation);
    applyButtons(finalChildOptions.topBar, child);
    applyTopBarOptions(finalChildOptions, stack, child);
    applyTopTabsOptions(finalChildOptions.topTabs);
    applyTopTabOptions(finalChildOptions.topTabOptions);
}
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 7 with Options

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

the class StackPresenter method onConfigurationChanged.

public void onConfigurationChanged(Options options) {
    if (topBar == null)
        return;
    Options withDefault = options.copy().withDefaultOptions(defaultOptions);
    if (currentRightButtons != null && !currentRightButtons.isEmpty())
        topBarController.applyRightButtons(currentRightButtons);
    if (currentLeftButtons != null && !currentLeftButtons.isEmpty())
        topBarController.applyLeftButtons(currentLeftButtons);
    if (withDefault.topBar.buttons.back.visible.isTrue()) {
        topBar.setBackButton(createButtonController(withDefault.topBar.buttons.back));
    }
    topBar.setOverflowButtonColor(withDefault.topBar.rightButtonColor.get(Color.BLACK));
    topBar.applyTopTabsColors(withDefault.topTabs.selectedTabColor, withDefault.topTabs.unselectedTabColor);
    topBar.setBorderColor(withDefault.topBar.borderColor.get(DEFAULT_BORDER_COLOR));
    topBar.setBackgroundColor(withDefault.topBar.background.color.get(Color.WHITE));
    topBar.setTitleTextColor(withDefault.topBar.title.color.get(TopBar.DEFAULT_TITLE_COLOR));
    topBar.setSubtitleColor(withDefault.topBar.subtitle.color.get(TopBar.DEFAULT_TITLE_COLOR));
}
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 8 with Options

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

the class TestUtils method newStackController.

public static StackControllerBuilder newStackController(Activity activity) {
    TopBarController topBarController = new TopBarController() {

        @Override
        protected TopBar createTopBar(@NonNull Context context, @NonNull StackLayout stackLayout) {
            TopBar topBar = super.createTopBar(context, stackLayout);
            topBar.layout(0, 0, 1000, UiUtils.getTopBarHeight(context));
            return topBar;
        }
    };
    return new StackControllerBuilder(activity, Mockito.mock(EventEmitter.class)).setId("stack" + CompatUtils.generateViewId()).setChildRegistry(new ChildControllersRegistry()).setTopBarController(topBarController).setStackPresenter(new StackPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TitleBarButtonCreatorMock(), new IconResolver(activity, new ImageLoader()), new TypefaceLoaderMock(), new RenderChecker(), new Options())).setInitialOptions(new Options());
}
Also used : Context(android.content.Context) Options(com.reactnativenavigation.options.Options) IconResolver(com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TitleBarButtonCreatorMock(com.reactnativenavigation.mocks.TitleBarButtonCreatorMock) TypefaceLoaderMock(com.reactnativenavigation.mocks.TypefaceLoaderMock) TopBarBackgroundViewCreatorMock(com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock) TitleBarReactViewCreatorMock(com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock) NonNull(androidx.annotation.NonNull) StackLayout(com.reactnativenavigation.views.stack.StackLayout) StackPresenter(com.reactnativenavigation.viewcontrollers.stack.StackPresenter) TopBar(com.reactnativenavigation.views.stack.topbar.TopBar) StackControllerBuilder(com.reactnativenavigation.viewcontrollers.stack.StackControllerBuilder) ImageLoader(com.reactnativenavigation.utils.ImageLoader) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController) RenderChecker(com.reactnativenavigation.utils.RenderChecker)

Example 9 with Options

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

the class PresenterTest method shouldApplyInsetsOnTopMostParent.

@Test
public void shouldApplyInsetsOnTopMostParent() {
    final ViewGroup spy = Mockito.mock(ViewGroup.class);
    Mockito.when(spy.getLayoutParams()).thenReturn(new ViewGroup.LayoutParams(0, 0));
    Mockito.when(controller.getView()).thenReturn(spy);
    Options options = new Options();
    options.layout.setInsets(new LayoutInsets(1, 2, 3, 4));
    uut.applyOptions(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)

Example 10 with Options

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

the class PresenterTest method mergeStatusBarVisible_callsShowHide.

@Test
public void mergeStatusBarVisible_callsShowHide() {
    mockSystemUiUtils(1, 1, (mockedStatic) -> {
        ViewGroup spy = spy(new FrameLayout(activity));
        Mockito.when(controller.getView()).thenReturn(spy);
        Mockito.when(controller.resolveCurrentOptions()).thenReturn(Options.EMPTY);
        Options options = new Options();
        options.statusBar.visible = new Bool(false);
        uut.mergeOptions(controller, options);
        mockedStatic.verify(() -> SystemUiUtils.hideStatusBar(any(), eq(spy)), times(1));
        options.statusBar.visible = new Bool(true);
        uut.mergeOptions(controller, options);
        mockedStatic.verify(() -> SystemUiUtils.showStatusBar(any(), eq(spy)), times(1));
    });
}
Also used : Options(com.reactnativenavigation.options.Options) Bool(com.reactnativenavigation.options.params.Bool) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) 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