react-native-navigation的迁移库

LayoutFactory.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.reactnativenavigation.layouts;
  2. import android.support.v7.app.AppCompatActivity;
  3. import android.util.Log;
  4. import com.reactnativenavigation.params.ActivityParams;
  5. public class LayoutFactory {
  6. public static Layout create(AppCompatActivity activity, ActivityParams params) {
  7. switch (params.type) {
  8. case TabBased:
  9. return createBottomTabsScreenLayout(activity, params);
  10. case SingleScreen:
  11. default:
  12. return createSingleScreenLayout(activity, params);
  13. }
  14. }
  15. private static Layout createSingleScreenLayout(AppCompatActivity activity, ActivityParams params) {
  16. return new SingleScreenLayout(activity, params.leftSideMenuParams, params.rightSideMenuParams, params.screenParams);
  17. }
  18. private static Layout createBottomTabsScreenLayout(AppCompatActivity activity, ActivityParams params) {
  19. if (params.tabParams.size() > 5) {
  20. removeAllButTheFirst5Tabs(params);
  21. }
  22. return new BottomTabsLayout(activity, params);
  23. }
  24. private static void removeAllButTheFirst5Tabs(ActivityParams params) {
  25. Log.e("Navigation", "LayoutFactory:createBottomTabsScreenLayout() does not support more than 5 tabs, currently");
  26. while (params.tabParams.size() > 5) {
  27. params.tabParams.remove(params.tabParams.size() - 1);
  28. }
  29. }
  30. }