Search in sources :

Example 1 with TopBarController

use of com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController in project react-native-navigation by wix.

the class OptionsApplyingTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    initialNavigationOptions = new Options();
    view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
    view.asView().setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, initialNavigationOptions, new Presenter(activity, new Options()), new ComponentPresenter(Options.EMPTY)) {

        @Override
        public boolean isViewShown() {
            return true;
        }
    };
    TopBarController topBarController = new TopBarController() {

        @Override
        protected TopBar createTopBar(Context context, StackLayout stackLayout) {
            topBar = spy(super.createTopBar(context, stackLayout));
            return topBar;
        }
    };
    stack = TestUtils.newStackController(activity).setTopBarController(topBarController).build();
    stack.ensureViewIsCreated();
    stack.getView().layout(0, 0, 1000, 1000);
    stack.getTopBar().layout(0, 0, 1000, 100);
    activity.setContentView(stack.getView());
    disablePushAnimation(uut);
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) TopBar(com.reactnativenavigation.views.stack.topbar.TopBar) Context(android.content.Context) Text(com.reactnativenavigation.options.params.Text) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) StackLayout(com.reactnativenavigation.views.stack.StackLayout) Java6Assertions.assertThat(org.assertj.core.api.Java6Assertions.assertThat) IReactView(com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView) ColorDrawable(android.graphics.drawable.ColorDrawable) Colour(com.reactnativenavigation.options.params.Colour) Mockito.spy(org.mockito.Mockito.spy) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController) View(android.view.View) Bool(com.reactnativenavigation.options.params.Bool) BaseTest(com.reactnativenavigation.BaseTest) MATCH_PARENT(android.view.ViewGroup.LayoutParams.MATCH_PARENT) Test(org.junit.Test) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) Color(android.graphics.Color) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TestReactView(com.reactnativenavigation.mocks.TestReactView) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) Options(com.reactnativenavigation.options.Options) Configuration(android.content.res.Configuration) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TestUtils(com.reactnativenavigation.TestUtils) RelativeLayout(android.widget.RelativeLayout) TestComponentLayout(com.reactnativenavigation.mocks.TestComponentLayout) Activity(android.app.Activity) Context(android.content.Context) Options(com.reactnativenavigation.options.Options) TestReactView(com.reactnativenavigation.mocks.TestReactView) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TestComponentLayout(com.reactnativenavigation.mocks.TestComponentLayout) RelativeLayout(android.widget.RelativeLayout) StackLayout(com.reactnativenavigation.views.stack.StackLayout) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)

Example 2 with TopBarController

use of com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController 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 3 with TopBarController

use of com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController in project react-native-navigation by wix.

the class TopBarTest method beforeEach.

@Override
public void beforeEach() {
    activity = newActivity();
    StackLayout parent = new StackLayout(activity, new TopBarController(), null);
    uut = new TopBar(activity);
    parent.addView(uut);
}
Also used : StackLayout(com.reactnativenavigation.views.stack.StackLayout) TopBar(com.reactnativenavigation.views.stack.topbar.TopBar) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)

Aggregations

TopBarController (com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)3 StackLayout (com.reactnativenavigation.views.stack.StackLayout)3 TopBar (com.reactnativenavigation.views.stack.topbar.TopBar)3 Context (android.content.Context)2 Options (com.reactnativenavigation.options.Options)2 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)2 Activity (android.app.Activity)1 Configuration (android.content.res.Configuration)1 Color (android.graphics.Color)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 MATCH_PARENT (android.view.ViewGroup.LayoutParams.MATCH_PARENT)1 RelativeLayout (android.widget.RelativeLayout)1 NonNull (androidx.annotation.NonNull)1 BaseTest (com.reactnativenavigation.BaseTest)1 TestUtils (com.reactnativenavigation.TestUtils)1 TestComponentLayout (com.reactnativenavigation.mocks.TestComponentLayout)1 TestReactView (com.reactnativenavigation.mocks.TestReactView)1 TitleBarButtonCreatorMock (com.reactnativenavigation.mocks.TitleBarButtonCreatorMock)1 TitleBarReactViewCreatorMock (com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock)1