react-native-navigation的迁移库

TestUtils.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.reactnativenavigation;
  2. import android.app.Activity;
  3. import android.content.Context;
  4. import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
  5. import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
  6. import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
  7. import com.reactnativenavigation.parse.Options;
  8. import com.reactnativenavigation.presentation.StackOptionsPresenter;
  9. import com.reactnativenavigation.utils.ImageLoader;
  10. import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
  11. import com.reactnativenavigation.viewcontrollers.ReactViewCreator;
  12. import com.reactnativenavigation.viewcontrollers.TopBarButtonController;
  13. import com.reactnativenavigation.viewcontrollers.stack.StackControllerBuilder;
  14. import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
  15. import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
  16. import com.reactnativenavigation.views.StackLayout;
  17. import com.reactnativenavigation.views.titlebar.TitleBarReactViewCreator;
  18. import com.reactnativenavigation.views.topbar.TopBar;
  19. public class TestUtils {
  20. public static StackControllerBuilder newStackController(Activity activity) {
  21. return new StackControllerBuilder(activity)
  22. .setId("stack")
  23. .setChildRegistry(new ChildControllersRegistry())
  24. .setTopBarButtonCreator(new TopBarButtonCreatorMock())
  25. .setTitleBarReactViewCreator(new TitleBarReactViewCreatorMock())
  26. .setTopBarBackgroundViewController(new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()))
  27. .setTopBarController(new TopBarController() {
  28. @Override
  29. protected TopBar createTopBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener topBarButtonClickListener, StackLayout stackLayout, ImageLoader imageLoader) {
  30. TopBar topBar = super.createTopBar(context, buttonCreator, titleBarReactViewCreator, topBarBackgroundViewController, topBarButtonClickListener, stackLayout, imageLoader);
  31. topBar.layout(0, 0, 1000, 100);
  32. return topBar;
  33. }
  34. })
  35. .setStackPresenter(new StackOptionsPresenter(activity, new Options()))
  36. .setInitialOptions(new Options());
  37. }
  38. }