Search in sources :

Example 56 with Options

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

the class BottomTabPresenterTest method createBottomTabs.

private void createBottomTabs(Options tab1Options, Options tab2Options, Options tab3Options) {
    childRegistry = new ChildControllersRegistry();
    bottomTabs = Mockito.mock(BottomTabs.class);
    child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tab1Options));
    child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tab2Options));
    child3 = spy(new SimpleViewController(activity, childRegistry, "child2", tab3Options));
    tabs = Arrays.asList(child1, child2, child3);
    uut = new BottomTabPresenter(activity, tabs, ImageLoaderMock.mock(), new TypefaceLoaderMock(), new Options());
    uut.bindView(bottomTabs);
    uut.setDefaultOptions(new Options());
}
Also used : BottomTabs(com.reactnativenavigation.views.bottomtabs.BottomTabs) Options(com.reactnativenavigation.options.Options) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) TypefaceLoaderMock(com.reactnativenavigation.mocks.TypefaceLoaderMock)

Example 57 with Options

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

the class BottomTabPresenterTest method createTab1Options.

private Options createTab1Options() {
    Options options = new Options();
    options.bottomTabOptions.badge = new Text("tab1badge");
    options.bottomTabOptions.iconColor = new ThemeColour(new Colour(Color.RED));
    options.bottomTabOptions.selectedIconColor = new ThemeColour(new Colour(Color.RED));
    return options;
}
Also used : Options(com.reactnativenavigation.options.Options) Text(com.reactnativenavigation.options.params.Text) NullText(com.reactnativenavigation.options.params.NullText) NullThemeColour(com.reactnativenavigation.options.params.NullThemeColour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) NullThemeColour(com.reactnativenavigation.options.params.NullThemeColour) Colour(com.reactnativenavigation.options.params.Colour) DontApplyColour(com.reactnativenavigation.options.params.DontApplyColour) ThemeColour(com.reactnativenavigation.options.params.ThemeColour)

Example 58 with Options

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

the class BottomTabsController method handleBack.

@Override
public boolean handleBack(CommandListener listener) {
    final boolean childBack = !tabs.isEmpty() && tabs.get(bottomTabs.getCurrentItem()).handleBack(listener);
    final Options options = resolveCurrentOptions();
    if (!childBack) {
        if (options.hardwareBack.getBottomTabOnPress() instanceof HwBackBottomTabsBehaviour.PrevSelection) {
            if (!selectionStack.isEmpty()) {
                final int prevSelectedTabIndex = selectionStack.poll();
                selectTab(prevSelectedTabIndex, false);
                return true;
            }
        } else if (options.hardwareBack.getBottomTabOnPress() instanceof HwBackBottomTabsBehaviour.JumpToFirst) {
            if (getSelectedIndex() != 0) {
                selectTab(0, false);
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    return childBack;
}
Also used : BottomTabOptions(com.reactnativenavigation.options.BottomTabOptions) Options(com.reactnativenavigation.options.Options) HwBackBottomTabsBehaviour(com.reactnativenavigation.options.HwBackBottomTabsBehaviour)

Example 59 with Options

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

the class ComponentPresenter method onConfigurationChanged.

public void onConfigurationChanged(ComponentLayout view, Options options) {
    if (view == null)
        return;
    Options withDefault = options.withDefaultOptions(defaultOptions);
    setBackgroundColor(view, withDefault);
}
Also used : Options(com.reactnativenavigation.options.Options)

Example 60 with Options

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

the class ParentControllerTest method mergeOptions_optionsAreMergedWhenChildAppears.

@Test
public void mergeOptions_optionsAreMergedWhenChildAppears() {
    Options options = new Options();
    options.topBar.title.text = new Text("new title");
    ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
    children.add(child1);
    uut.ensureViewIsCreated();
    child1.ensureViewIsCreated();
    child1.onViewWillAppear();
    ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
    verify(uut, times(1)).clearOptions();
    verify(uut, times(1)).applyChildOptions(optionsCaptor.capture(), eq(child1));
    assertThat(optionsCaptor.getValue().topBar.title.text.get()).isEqualTo("new title");
}
Also used : Options(com.reactnativenavigation.options.Options) Text(com.reactnativenavigation.options.params.Text) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) 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