react-native-navigation的迁移库

TestUtils.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.parse.params.Bool;
  9. import com.reactnativenavigation.presentation.StackOptionsPresenter;
  10. import com.reactnativenavigation.utils.ImageLoader;
  11. import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
  12. import com.reactnativenavigation.viewcontrollers.ViewController;
  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.topbar.TopBar;
  18. public class TestUtils {
  19. public static StackControllerBuilder newStackController(Activity activity) {
  20. return new StackControllerBuilder(activity)
  21. .setId("stack")
  22. .setChildRegistry(new ChildControllersRegistry())
  23. .setTopBarButtonCreator(new TopBarButtonCreatorMock())
  24. .setTopBarBackgroundViewController(new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()))
  25. .setTopBarController(new TopBarController() {
  26. @Override
  27. protected TopBar createTopBar(Context context, TopBarBackgroundViewController topBarBackgroundViewController, StackLayout stackLayout) {
  28. TopBar topBar = super.createTopBar(context, topBarBackgroundViewController, stackLayout);
  29. topBar.layout(0, 0, 1000, 100);
  30. return topBar;
  31. }
  32. })
  33. .setStackPresenter(new StackOptionsPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarButtonCreatorMock(), new ImageLoader(), new Options()) )
  34. .setInitialOptions(new Options());
  35. }
  36. public static void hideBackButton(ViewController viewController) {
  37. viewController.options.topBar.buttons.back.visible = new Bool(false);
  38. }
  39. }