react-native-navigation的迁移库

TestUtils.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.StackPresenter;
  10. import com.reactnativenavigation.utils.ImageLoader;
  11. import com.reactnativenavigation.utils.UiUtils;
  12. import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
  13. import com.reactnativenavigation.viewcontrollers.ViewController;
  14. import com.reactnativenavigation.viewcontrollers.stack.StackControllerBuilder;
  15. import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
  16. import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
  17. import com.reactnativenavigation.views.StackLayout;
  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. .setTopBarBackgroundViewController(new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()))
  26. .setTopBarController(new TopBarController() {
  27. @Override
  28. protected TopBar createTopBar(Context context, TopBarBackgroundViewController topBarBackgroundViewController, StackLayout stackLayout) {
  29. TopBar topBar = super.createTopBar(context, topBarBackgroundViewController, stackLayout);
  30. topBar.layout(0, 0, 1000, UiUtils.getTopBarHeight(context));
  31. return topBar;
  32. }
  33. })
  34. .setStackPresenter(new StackPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarButtonCreatorMock(), new ImageLoader(), new Options()) )
  35. .setInitialOptions(new Options());
  36. }
  37. public static void hideBackButton(ViewController viewController) {
  38. viewController.options.topBar.buttons.back.visible = new Bool(false);
  39. }
  40. }